From 388bdab93358066cd9c0cfd352cbf8150b083d44 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:25:43 -0400 Subject: [PATCH 001/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index d4578ec4e73..645579027c2 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,8 +1,10 @@ -pragma solidity ^0.4.23; - -import "../token/ERC20/ERC20.sol"; -import "../math/SafeMath.sol"; +pragma solidity ^0.8.4; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/MintableToken.sol"; +import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol"; +import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol"; /** * @title Crowdsale From 233e5641d3211728cf3f828f4f007314b720b56a Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:33:06 -0400 Subject: [PATCH 002/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 0fd454e3412..e687fa96f5b 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,6 +1,6 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "./ERC20Basic.sol"; +import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol"; /** From b5477e02d855c23b18ddc75521a5667472b6f92f Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:35:26 -0400 Subject: [PATCH 003/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 1042c2f17e2..f8ad8feb717 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,8 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; - -import "./ERC20Basic.sol"; -import "../../math/SafeMath.sol"; +import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** From 877faa121cc6363a88be62675a8dc966db546259 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:38:29 -0400 Subject: [PATCH 004/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 87c03282509..50976aa71ab 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; /** From 0b6d22e745aaee8ce84a5d83ab861731d1abddd0 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:41:21 -0400 Subject: [PATCH 005/141] Update Ownable.sol --- contracts/ownership/Ownable.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index f1c73742765..d3c78b8d83f 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; /** From 018180f44a3087693ba3b9903ddb74429782fb5e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:42:03 -0400 Subject: [PATCH 006/141] Update MintableToken.sol --- contracts/token/ERC20/MintableToken.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/MintableToken.sol b/contracts/token/ERC20/MintableToken.sol index 590a3065895..231c9b5539a 100644 --- a/contracts/token/ERC20/MintableToken.sol +++ b/contracts/token/ERC20/MintableToken.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "./StandardToken.sol"; -import "../../ownership/Ownable.sol"; +import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; /** From 66642a8708ff4ca2387ce31b45aeacd903cb91ec Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:54:20 -0400 Subject: [PATCH 007/141] Update BurnableToken.sol --- contracts/token/ERC20/BurnableToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/BurnableToken.sol b/contracts/token/ERC20/BurnableToken.sol index ad5c0ab8b1c..7fc902c05d9 100644 --- a/contracts/token/ERC20/BurnableToken.sol +++ b/contracts/token/ERC20/BurnableToken.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; import "./BasicToken.sol"; From c97a1db69dc81a415d5d60bcd8cad2546c7f68d9 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:54:58 -0400 Subject: [PATCH 008/141] Update DetailedERC20.sol --- contracts/token/ERC20/DetailedERC20.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/DetailedERC20.sol b/contracts/token/ERC20/DetailedERC20.sol index 749d960712d..402bb1ef4ca 100644 --- a/contracts/token/ERC20/DetailedERC20.sol +++ b/contracts/token/ERC20/DetailedERC20.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; import "./ERC20.sol"; From e1265cd4d31dd55d6f7554cae7b421a46e4bc322 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:55:27 -0400 Subject: [PATCH 009/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 4f02de19eed..664da8c3f63 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; /** From d4c25b88cbf7e8ce0dd27715bba528aa86a255fe Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:55:55 -0400 Subject: [PATCH 010/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 664da8c3f63..25ea1f38aa0 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,6 +1,5 @@ pragma solidity ^0.8.4; - /** * @title ERC20Basic * @dev Simpler version of ERC20 interface From 0b44ff8c5c4aca73ac2b879e059d72c3dd09f0d2 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 22:57:09 -0400 Subject: [PATCH 011/141] Update SafeERC20.sol --- contracts/token/ERC20/SafeERC20.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 4994ce49c50..f2a6128144b 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; import "./ERC20Basic.sol"; import "./ERC20.sol"; From 45ab3d49f21b2c39118a71e597a5c3e1bc433d77 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:03:11 -0400 Subject: [PATCH 012/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index e687fa96f5b..b2cf2b2f5f8 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,7 +1,8 @@ pragma solidity ^0.8.4; -import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol"; - +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol"; /** * @title ERC20 interface From 4ec5b7085251f7f059983a866cb9111427b82168 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:04:00 -0400 Subject: [PATCH 013/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 645579027c2..ffe872d4b0e 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,6 +1,9 @@ pragma solidity ^0.8.4; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/MintableToken.sol"; import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol"; From dbfafbfe71e1a627312c1a563f063974563f817a Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:12:30 -0400 Subject: [PATCH 014/141] Create IERC20.sol --- contracts/token/ERC20/IERC20.sol | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 contracts/token/ERC20/IERC20.sol diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol new file mode 100644 index 00000000000..28d73cbf8ab --- /dev/null +++ b/contracts/token/ERC20/IERC20.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +/** + * @dev Interface of the ERC20 standard as defined in the EIP. + */ +interface IERC20 { + /** + * @dev Returns the amount of tokens in existence. + */ + function totalSupply() external view returns (uint256); + + /** + * @dev Returns the amount of tokens owned by `account`. + */ + function balanceOf(address account) external view returns (uint256); + + /** + * @dev Moves `amount` tokens from the caller's account to `recipient`. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transfer(address recipient, uint256 amount) external returns (bool); + + /** + * @dev Returns the remaining number of tokens that `spender` will be + * allowed to spend on behalf of `owner` through {transferFrom}. This is + * zero by default. + * + * This value changes when {approve} or {transferFrom} are called. + */ + function allowance(address owner, address spender) external view returns (uint256); + + /** + * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * IMPORTANT: Beware that changing an allowance with this method brings the risk + * that someone may use both the old and the new allowance by unfortunate + * transaction ordering. One possible solution to mitigate this race + * condition is to first reduce the spender's allowance to 0 and set the + * desired value afterwards: + * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 + * + * Emits an {Approval} event. + */ + function approve(address spender, uint256 amount) external returns (bool); + + /** + * @dev Moves `amount` tokens from `sender` to `recipient` using the + * allowance mechanism. `amount` is then deducted from the caller's + * allowance. + * + * Returns a boolean value indicating whether the operation succeeded. + * + * Emits a {Transfer} event. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); + + /** + * @dev Emitted when `value` tokens are moved from one account (`from`) to + * another (`to`). + * + * Note that `value` may be zero. + */ + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Emitted when the allowance of a `spender` for an `owner` is set by + * a call to {approve}. `value` is the new allowance. + */ + event Approval(address indexed owner, address indexed spender, uint256 value); +} From be434b048d2c34659e7fe1019718bf7713d2bb3c Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:15:25 -0400 Subject: [PATCH 015/141] Create IERC20Metadata.sol --- contracts/token/ERC20/IERC20Metadata.sol | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 contracts/token/ERC20/IERC20Metadata.sol diff --git a/contracts/token/ERC20/IERC20Metadata.sol b/contracts/token/ERC20/IERC20Metadata.sol new file mode 100644 index 00000000000..2535622ac8a --- /dev/null +++ b/contracts/token/ERC20/IERC20Metadata.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; + +/** + * @dev Interface for the optional metadata functions from the ERC20 standard. + * + * _Available since v4.1._ + */ +interface IERC20Metadata is IERC20 { + /** + * @dev Returns the name of the token. + */ + function name() external view returns (string memory); + + /** + * @dev Returns the symbol of the token. + */ + function symbol() external view returns (string memory); + + /** + * @dev Returns the decimals places of the token. + */ + function decimals() external view returns (uint8); +} From 37630bfa891192d513e0ce9dd5d7180894da0685 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:16:46 -0400 Subject: [PATCH 016/141] Update IERC20Metadata.sol --- contracts/token/ERC20/IERC20Metadata.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/IERC20Metadata.sol b/contracts/token/ERC20/IERC20Metadata.sol index 2535622ac8a..b1c51954950 100644 --- a/contracts/token/ERC20/IERC20Metadata.sol +++ b/contracts/token/ERC20/IERC20Metadata.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; +pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; From bfc22d8399fd8701ae2af2aca4dc366252207db3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:17:44 -0400 Subject: [PATCH 017/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index ffe872d4b0e..5ff1debcaaf 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.4; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/MintableToken.sol"; From 68b600162c27b7fbd029f4be1c4375969c78bf2f Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:20:47 -0400 Subject: [PATCH 018/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index b2cf2b2f5f8..a6b39bdbbfd 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,7 +1,7 @@ pragma solidity ^0.8.4; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol"; /** From 3129e06c6bbab76306c00c012efd2b01d216799e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:23:34 -0400 Subject: [PATCH 019/141] Create Context.sol --- contracts/token/ERC20/Context.sol | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 contracts/token/ERC20/Context.sol diff --git a/contracts/token/ERC20/Context.sol b/contracts/token/ERC20/Context.sol new file mode 100644 index 00000000000..51853cdcb0a --- /dev/null +++ b/contracts/token/ERC20/Context.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +/** + * @dev Provides information about the current execution context, including the + * sender of the transaction and its data. While these are generally available + * via msg.sender and msg.data, they should not be accessed in such a direct + * manner, since when dealing with meta-transactions the account sending and + * paying for execution may not be the actual sender (as far as an application + * is concerned). + * + * This contract is only required for intermediate, library-like contracts. + */ +abstract contract Context { + function _msgSender() internal view virtual returns (address) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes calldata) { + return msg.data; + } +} From aef56aa30a87821f1dd69c78f62517f8afa7890e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:02:36 -0400 Subject: [PATCH 020/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index 67310dbc6df..f69a841dc45 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./BasicToken.sol"; -import "./ERC20.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; /** From a170a0dde4fe3da2157c3954c19a8807969567d9 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:04:17 -0400 Subject: [PATCH 021/141] Update CappedToken.sol --- contracts/token/ERC20/CappedToken.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/CappedToken.sol b/contracts/token/ERC20/CappedToken.sol index d8e67ac636a..bd74f4b6bea 100644 --- a/contracts/token/ERC20/CappedToken.sol +++ b/contracts/token/ERC20/CappedToken.sol @@ -1,7 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./MintableToken.sol"; +pragma solidity ^0.8.4; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; /** * @title Capped token From b503fa40613251ee3c2407fa3d5097967fc61c98 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:08:26 -0400 Subject: [PATCH 022/141] Update PausableToken.sol --- contracts/token/ERC20/PausableToken.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/PausableToken.sol b/contracts/token/ERC20/PausableToken.sol index 28c622df5fb..bfacafa56ba 100644 --- a/contracts/token/ERC20/PausableToken.sol +++ b/contracts/token/ERC20/PausableToken.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./StandardToken.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; import "../../lifecycle/Pausable.sol"; From 5712c81879c74feb7f76bd5a9e44a54ab92ed9aa Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:12:37 -0400 Subject: [PATCH 023/141] Create Pausable.sol --- contracts/token/ERC20/Pausable.sol | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 contracts/token/ERC20/Pausable.sol diff --git a/contracts/token/ERC20/Pausable.sol b/contracts/token/ERC20/Pausable.sol new file mode 100644 index 00000000000..20e33bb9514 --- /dev/null +++ b/contracts/token/ERC20/Pausable.sol @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; + + +/** + * @title Pausable + * @dev Base contract which allows children to implement an emergency stop mechanism. + */ +contract Pausable is Ownable { + event Pause(); + event Unpause(); + + bool public paused = false; + + + /** + * @dev Modifier to make a function callable only when the contract is not paused. + */ + modifier whenNotPaused() { + require(!paused); + _; + } + + /** + * @dev Modifier to make a function callable only when the contract is paused. + */ + modifier whenPaused() { + require(paused); + _; + } + + /** + * @dev called by the owner to pause, triggers stopped state + */ + function pause() onlyOwner whenNotPaused public { + paused = true; + emit Pause(); + } + + /** + * @dev called by the owner to unpause, returns to normal state + */ + function unpause() onlyOwner whenPaused public { + paused = false; + emit Unpause(); + } +} From 2142c67e281fb5ce03dad3e3e4282ae717689511 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:19:23 -0400 Subject: [PATCH 024/141] Update SafeERC20.sol --- contracts/token/ERC20/SafeERC20.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index f2a6128144b..3dc721a34be 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,7 +1,9 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; -import "./ERC20Basic.sol"; -import "./ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; /** From ae7c797025da0c21cd220ef342376b55e30cfea3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:20:28 -0400 Subject: [PATCH 025/141] Update TokenTimelock.sol --- contracts/token/ERC20/TokenTimelock.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 8556a533aa7..893beff8667 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./SafeERC20.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeERC20.sol"; /** From e86b06d9c2ed0ef2a5c3f26f5bbbc5af41d81ab9 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:23:02 -0400 Subject: [PATCH 026/141] Create SafeMath.sol --- contracts/token/ERC20/SafeMath.sol | 226 +++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 contracts/token/ERC20/SafeMath.sol diff --git a/contracts/token/ERC20/SafeMath.sol b/contracts/token/ERC20/SafeMath.sol new file mode 100644 index 00000000000..112eed1a8e6 --- /dev/null +++ b/contracts/token/ERC20/SafeMath.sol @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +// CAUTION +// This version of SafeMath should only be used with Solidity 0.8 or later, +// because it relies on the compiler's built in overflow checks. + +/** + * @dev Wrappers over Solidity's arithmetic operations. + * + * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler + * now has built in overflow checking. + */ +library SafeMath { + /** + * @dev Returns the addition of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + uint256 c = a + b; + if (c < a) return (false, 0); + return (true, c); + } + } + + /** + * @dev Returns the substraction of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b > a) return (false, 0); + return (true, a - b); + } + } + + /** + * @dev Returns the multiplication of two unsigned integers, with an overflow flag. + * + * _Available since v3.4._ + */ + function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + // Gas optimization: this is cheaper than requiring 'a' not being zero, but the + // benefit is lost if 'b' is also tested. + // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 + if (a == 0) return (true, 0); + uint256 c = a * b; + if (c / a != b) return (false, 0); + return (true, c); + } + } + + /** + * @dev Returns the division of two unsigned integers, with a division by zero flag. + * + * _Available since v3.4._ + */ + function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a / b); + } + } + + /** + * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. + * + * _Available since v3.4._ + */ + function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { + unchecked { + if (b == 0) return (false, 0); + return (true, a % b); + } + } + + /** + * @dev Returns the addition of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `+` operator. + * + * Requirements: + * + * - Addition cannot overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256) { + return a + b; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting on + * overflow (when the result is negative). + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return a - b; + } + + /** + * @dev Returns the multiplication of two unsigned integers, reverting on + * overflow. + * + * Counterpart to Solidity's `*` operator. + * + * Requirements: + * + * - Multiplication cannot overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + return a * b; + } + + /** + * @dev Returns the integer division of two unsigned integers, reverting on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return a / b; + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * reverting when dividing by zero. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return a % b; + } + + /** + * @dev Returns the subtraction of two unsigned integers, reverting with custom message on + * overflow (when the result is negative). + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {trySub}. + * + * Counterpart to Solidity's `-` operator. + * + * Requirements: + * + * - Subtraction cannot overflow. + */ + function sub( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b <= a, errorMessage); + return a - b; + } + } + + /** + * @dev Returns the integer division of two unsigned integers, reverting with custom message on + * division by zero. The result is rounded towards zero. + * + * Counterpart to Solidity's `/` operator. Note: this function uses a + * `revert` opcode (which leaves remaining gas untouched) while Solidity + * uses an invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function div( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a / b; + } + } + + /** + * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), + * reverting with custom message when dividing by zero. + * + * CAUTION: This function is deprecated because it requires allocating memory for the error + * message unnecessarily. For custom revert reasons use {tryMod}. + * + * Counterpart to Solidity's `%` operator. This function uses a `revert` + * opcode (which leaves remaining gas untouched) while Solidity uses an + * invalid opcode to revert (consuming all remaining gas). + * + * Requirements: + * + * - The divisor cannot be zero. + */ + function mod( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { + unchecked { + require(b > 0, errorMessage); + return a % b; + } + } +} From c4b3a8866ec55ff36a5a7062c31bff518ce094ed Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:24:45 -0400 Subject: [PATCH 027/141] Update TokenVesting.sol --- contracts/token/ERC20/TokenVesting.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/token/ERC20/TokenVesting.sol b/contracts/token/ERC20/TokenVesting.sol index d078ba998a8..9ab272b4ace 100644 --- a/contracts/token/ERC20/TokenVesting.sol +++ b/contracts/token/ERC20/TokenVesting.sol @@ -1,11 +1,11 @@ /* solium-disable security/no-block-members */ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "./ERC20Basic.sol"; -import "./SafeERC20.sol"; -import "../../ownership/Ownable.sol"; -import "../../math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** From 9f8be96e4b36cf09c7b1e10c4df102246a62cc56 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:28:03 -0400 Subject: [PATCH 028/141] Update BurnableToken.sol --- contracts/token/ERC20/BurnableToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/BurnableToken.sol b/contracts/token/ERC20/BurnableToken.sol index 7fc902c05d9..0fb01be8a15 100644 --- a/contracts/token/ERC20/BurnableToken.sol +++ b/contracts/token/ERC20/BurnableToken.sol @@ -1,6 +1,6 @@ pragma solidity ^0.8.4; -import "./BasicToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; /** From c5d5a34b5d20b777e399b35ad282bc3788555dd6 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:28:50 -0400 Subject: [PATCH 029/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index f8ad8feb717..38bff7829c7 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,6 +1,5 @@ pragma solidity ^0.8.4; -import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; From b4d0881cdb0580ef0ab69b0e8956936bfb3f4c3e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:29:26 -0400 Subject: [PATCH 030/141] Update StandardBurnableToken.sol --- contracts/token/ERC20/StandardBurnableToken.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/StandardBurnableToken.sol b/contracts/token/ERC20/StandardBurnableToken.sol index 94ca1a7882f..92a16056129 100644 --- a/contracts/token/ERC20/StandardBurnableToken.sol +++ b/contracts/token/ERC20/StandardBurnableToken.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "./BurnableToken.sol"; -import "./StandardToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BurnableToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; /** From 167bf5787bb4ae3c42da9f12ccd1414d5ace8bd6 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:31:57 -0400 Subject: [PATCH 031/141] Update RBACMintableToken.sol --- contracts/token/ERC20/RBACMintableToken.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/RBACMintableToken.sol b/contracts/token/ERC20/RBACMintableToken.sol index 923d2fe3952..beadc445e30 100644 --- a/contracts/token/ERC20/RBACMintableToken.sol +++ b/contracts/token/ERC20/RBACMintableToken.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./MintableToken.sol"; -import "../../ownership/rbac/RBAC.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/rbac/RBAC.sol"; /** From 26f0d5e5430c71462eb7497e07ee4e761f9ffccc Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:32:57 -0400 Subject: [PATCH 032/141] Update Roles.sol --- contracts/ownership/rbac/Roles.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/ownership/rbac/Roles.sol b/contracts/ownership/rbac/Roles.sol index 842f8595ecc..3c8bedc0309 100644 --- a/contracts/ownership/rbac/Roles.sol +++ b/contracts/ownership/rbac/Roles.sol @@ -1,4 +1,6 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; /** From 0dd547b04b2c1ecac84ef8a86e567798cc864c2e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:33:30 -0400 Subject: [PATCH 033/141] Update RBAC.sol --- contracts/ownership/rbac/RBAC.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/ownership/rbac/RBAC.sol b/contracts/ownership/rbac/RBAC.sol index 4ecb9ce6f1e..da5f101257e 100644 --- a/contracts/ownership/rbac/RBAC.sol +++ b/contracts/ownership/rbac/RBAC.sol @@ -1,6 +1,8 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "./Roles.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/rbac/Roles.sol"; /** From 8d3856e06f3f7bd22eb3bcf52e23fbee7d5bbc12 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:34:34 -0400 Subject: [PATCH 034/141] Update BurnableToken.sol --- contracts/token/ERC20/BurnableToken.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/token/ERC20/BurnableToken.sol b/contracts/token/ERC20/BurnableToken.sol index 0fb01be8a15..a580a6ef7cf 100644 --- a/contracts/token/ERC20/BurnableToken.sol +++ b/contracts/token/ERC20/BurnableToken.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; From 76699590a06bc6b0fd9ffd1f5aa79ef042550f3b Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:34:49 -0400 Subject: [PATCH 035/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 38bff7829c7..a9394c0234e 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; From f5c57b8d30685f0a79cbe15ae61ef6ed93b26336 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:37:08 -0400 Subject: [PATCH 036/141] Update DetailedERC20.sol --- contracts/token/ERC20/DetailedERC20.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/token/ERC20/DetailedERC20.sol b/contracts/token/ERC20/DetailedERC20.sol index 402bb1ef4ca..7ac118a7972 100644 --- a/contracts/token/ERC20/DetailedERC20.sol +++ b/contracts/token/ERC20/DetailedERC20.sol @@ -1,6 +1,8 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; -import "./ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; contract DetailedERC20 is ERC20 { From 149196f829753f1f7c704722737fc3f1378251b9 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:37:48 -0400 Subject: [PATCH 037/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 25ea1f38aa0..83a52c1c4f3 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; /** From db976b2bef33c4f488fbea79579cdcd050cb39b1 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:39:52 -0400 Subject: [PATCH 038/141] Update MintableToken.sol --- contracts/token/ERC20/MintableToken.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/token/ERC20/MintableToken.sol b/contracts/token/ERC20/MintableToken.sol index 231c9b5539a..c077711535e 100644 --- a/contracts/token/ERC20/MintableToken.sol +++ b/contracts/token/ERC20/MintableToken.sol @@ -1,6 +1,8 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; -import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; From b33b6ca0aaf010aa1333f7c99fc7e97dc3d33543 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:41:03 -0400 Subject: [PATCH 039/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index a6b39bdbbfd..9784e630a00 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; From 2fc9d88b049394220d73f8ed1d856f136041121f Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:41:55 -0400 Subject: [PATCH 040/141] Update PausableToken.sol --- contracts/token/ERC20/PausableToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/PausableToken.sol b/contracts/token/ERC20/PausableToken.sol index bfacafa56ba..2c32bfe8e9d 100644 --- a/contracts/token/ERC20/PausableToken.sol +++ b/contracts/token/ERC20/PausableToken.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; -import "../../lifecycle/Pausable.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Pausable.sol"; /** From 9cb30865797e16b0875d645a60ae652387415efe Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:42:52 -0400 Subject: [PATCH 041/141] Update StandardBurnableToken.sol --- contracts/token/ERC20/StandardBurnableToken.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/token/ERC20/StandardBurnableToken.sol b/contracts/token/ERC20/StandardBurnableToken.sol index 92a16056129..9e10e52df55 100644 --- a/contracts/token/ERC20/StandardBurnableToken.sol +++ b/contracts/token/ERC20/StandardBurnableToken.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BurnableToken.sol"; From a86e9eec4f98692bf5d59b33f008f09a732853f0 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:43:54 -0400 Subject: [PATCH 042/141] Update TokenVesting.sol --- contracts/token/ERC20/TokenVesting.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/token/ERC20/TokenVesting.sol b/contracts/token/ERC20/TokenVesting.sol index 9ab272b4ace..abbb55c455e 100644 --- a/contracts/token/ERC20/TokenVesting.sol +++ b/contracts/token/ERC20/TokenVesting.sol @@ -1,4 +1,5 @@ /* solium-disable security/no-block-members */ +// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; From cab62af94bddc00b86c0cb616749dbb7499f34ef Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 21:53:08 -0400 Subject: [PATCH 043/141] Update IndividuallyCappedCrowdsale.sol --- .../crowdsale/validation/IndividuallyCappedCrowdsale.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index b60466c1646..821449302f7 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -1,8 +1,8 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; -import "../../ownership/Ownable.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; /** From 4abf2f071536e0d96ec7c86bae832f0bfd9e24d6 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 21:59:14 -0400 Subject: [PATCH 044/141] Update TimedCrowdsale.sol --- contracts/crowdsale/validation/TimedCrowdsale.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 28d6beeca9b..4cf0cea32d1 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.soll"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; /** From 7f63ec77ac2a4cfc0e10f4894346e5817fd423f8 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:01:35 -0400 Subject: [PATCH 045/141] Update WhitelistedCrowdsale.sol --- contracts/crowdsale/validation/WhitelistedCrowdsale.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/validation/WhitelistedCrowdsale.sol b/contracts/crowdsale/validation/WhitelistedCrowdsale.sol index ee4e164770b..d80cf5ab3b4 100644 --- a/contracts/crowdsale/validation/WhitelistedCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistedCrowdsale.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "../Crowdsale.sol"; -import "../../ownership/Ownable.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; /** From f5ffc6cc1be3f63bb597ce9dd85c48735b7af707 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:05:07 -0400 Subject: [PATCH 046/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 02ae3d16aaf..18f12dba32c 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,7 +1,7 @@ -pragma solidity ^0.4.23; +pragma solidity ^0.8.4; -import "../Crowdsale.sol"; -import "../../token/ERC20/MintableToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; /** From 0cb66b5d30cbd5615bd3ddb952b8ed8ccb214bff Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:13:22 -0400 Subject: [PATCH 047/141] Create PausableCrowdsale.sol --- .../validation/PausableCrowdsale.sol | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 contracts/crowdsale/validation/PausableCrowdsale.sol diff --git a/contracts/crowdsale/validation/PausableCrowdsale.sol b/contracts/crowdsale/validation/PausableCrowdsale.sol new file mode 100644 index 00000000000..b253f541ad6 --- /dev/null +++ b/contracts/crowdsale/validation/PausableCrowdsale.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Pausable.sol"; + +/** + * @title PausableCrowdsale + * @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role. + */ +contract PausableCrowdsale is Crowdsale, Pausable { + /** + * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. + * Use super to concatenate validations. + * Adds the validation that the crowdsale must not be paused. + * @param _beneficiary Address performing the token purchase + * @param _weiAmount Value in wei involved in the purchase + */ + function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused { + return super._preValidatePurchase(_beneficiary, _weiAmount); + } +} From c8b20a52a4f235cc48945ad9d70f5b6668f8e072 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:19:13 -0400 Subject: [PATCH 048/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 9784e630a00..32336861647 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -2,9 +2,9 @@ pragma solidity ^0.8.4; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; /** * @title ERC20 interface From 87d201673918424d320640df5480559ecaadee6f Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:19:39 -0400 Subject: [PATCH 049/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 5ff1debcaaf..0b69ba3fe27 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,13 +1,17 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; -import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/MintableToken.sol"; -import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol"; -import "https://github.com/ConsenSysMesh/openzeppelin-solidity/blob/master/contracts/token/ERC20/BasicToken.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; + + /** * @title Crowdsale From c5608afc5b8897fa8da696c04860d5aa6c1042b9 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:21:50 -0400 Subject: [PATCH 050/141] Update AllowanceCrowdsale.sol --- contracts/crowdsale/emission/AllowanceCrowdsale.sol | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index a79716b32f1..5c059785aae 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -1,8 +1,10 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../Crowdsale.sol"; -import "../../token/ERC20/ERC20.sol"; -import "../../math/SafeMath.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** From bca4019a1cc06e6c41424301a1ff6ae691119228 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:23:24 -0400 Subject: [PATCH 051/141] Update IncreasingPriceCrowdsale.sol --- contracts/crowdsale/price/IncreasingPriceCrowdsale.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 592749a0a1c..95b64e3d3e9 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -1,7 +1,9 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../validation/TimedCrowdsale.sol"; -import "../../math/SafeMath.sol"; +pragma solidity ^0.8.4; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/validation/TimedCrowdsale.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** From 1f7392bb5a0b1cdf02f613b8025877a96f79c42a Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:30:18 -0400 Subject: [PATCH 052/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 18f12dba32c..ff46a22dc16 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: MIT + pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From 1d9ca0edbd4c45669cf784f25768c96d39df5950 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:33:55 -0400 Subject: [PATCH 053/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index ff46a22dc16..ec79a531d70 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; From d9196adce56454032328cf4b0391a83bbadbbe17 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:35:16 -0400 Subject: [PATCH 054/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index ec79a531d70..18f12dba32c 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: UNLICENSED - pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From 63a9e44fab3edb075aa3547b731477c8da0764c5 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:42:00 -0400 Subject: [PATCH 055/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 18f12dba32c..aaffa033802 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: + pragma solidity ^0.8.4; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From c8bd05cb2b4ab8586ebaf7fa0a1354041adfbf7e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 22:44:58 -0400 Subject: [PATCH 056/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 50976aa71ab..9669468dab5 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: + pragma solidity ^0.8.4; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; From 9f800762c22d5e069909171c81603061ca611e48 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 23:18:38 -0400 Subject: [PATCH 057/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 0b69ba3fe27..8001664657f 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -76,9 +76,7 @@ contract Crowdsale { /** * @dev fallback function ***DO NOT OVERRIDE*** */ - function () external payable { - buyTokens(msg.sender); - } + /** * @dev low level token purchase ***DO NOT OVERRIDE*** @@ -87,6 +85,7 @@ contract Crowdsale { function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; + buyTokens(msg.sender); _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created From c1efcb15e8c7e33a1624615ae124eb0ab5139d85 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 23:47:05 -0400 Subject: [PATCH 058/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index f69a841dc45..cef4ee76098 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.23; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; From d42b880d5b5e3fe7bd51539cd73058bdb84a7e11 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 31 Aug 2021 23:52:41 -0400 Subject: [PATCH 059/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index cef4ee76098..0a11aff4899 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.23; +pragma solidity ^0.4.23; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; From 87a18ba0a72f82fdfc062394c0d97f30f8cc0c4e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 00:01:47 -0400 Subject: [PATCH 060/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 6 ------ 1 file changed, 6 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 8001664657f..7c78c9035cd 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -73,11 +73,6 @@ contract Crowdsale { // Crowdsale external interface // ----------------------------------------- - /** - * @dev fallback function ***DO NOT OVERRIDE*** - */ - - /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase @@ -85,7 +80,6 @@ contract Crowdsale { function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; - buyTokens(msg.sender); _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created From 31a5a0dae49770f7a572acfcfe249dd76bde3b42 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 14:48:57 -0400 Subject: [PATCH 061/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index aaffa033802..34243f08b2a 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,6 +1,5 @@ -// SPDX-License-Identifier: -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; From 1f2c4fbdee1114085566dc6c5cb68e3053a837d9 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 14:51:45 -0400 Subject: [PATCH 062/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 9669468dab5..dee9c79aff8 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,6 +1,5 @@ -// SPDX-License-Identifier: -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From 9b3bb07b204e687fc33b07f125f60438d1465483 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:19:19 -0400 Subject: [PATCH 063/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 34243f08b2a..da8e6540bfc 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Universal Permissive License v1.0 pragma solidity ^0.8.7; From 8c747f85e57e37ffb680b48de2e10e9cf6dbedc7 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:19:43 -0400 Subject: [PATCH 064/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index dee9c79aff8..a53468dd448 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Universal Permissive License v1.0 pragma solidity ^0.8.7; From b660d71a1dfcbf76d9fdc1237c9a11642839c1f7 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:21:04 -0400 Subject: [PATCH 065/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index da8e6540bfc..7a052db5f4f 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Universal Permissive License v1.0 +// SPDX-License-Identifier: pragma solidity ^0.8.7; From b6b325813f9014a5e72da6784c5062eedb11637a Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:21:16 -0400 Subject: [PATCH 066/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index a53468dd448..e6441e9719d 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Universal Permissive License v1.0 +// SPDX-License-Identifier: pragma solidity ^0.8.7; From 59eb799517fa6683a8a82e272ca4bcf4da741e6d Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:25:40 -0400 Subject: [PATCH 067/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index 0a11aff4899..c04f05774c8 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: -pragma solidity ^0.4.23; +pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; From 518eab64b081eae677d6ecf837af63f2191550f8 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:27:56 -0400 Subject: [PATCH 068/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 7c78c9035cd..03bb146be7d 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; From 442dac8a8ddefd0482b6eac1b09ae45e621a6b79 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:37:45 -0400 Subject: [PATCH 069/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index e6441e9719d..7a279042765 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: +// SPDX-License-Identifier: MIT License Modern Variant pragma solidity ^0.8.7; From ddec4b454e88639bdcc51f6d94843d4a2f4ea5e7 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:38:02 -0400 Subject: [PATCH 070/141] Update MintedCrowdsale.sol --- contracts/crowdsale/emission/MintedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 7a052db5f4f..5d1c73f7574 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: +// SPDX-License-Identifier: MIT License Modern Variant pragma solidity ^0.8.7; From 848995b5e2df83ef78fe47d17f51356d3b453c80 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:38:15 -0400 Subject: [PATCH 071/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 03bb146be7d..c613514f63e 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: +// SPDX-License-Identifier: MIT License Modern Variant pragma solidity ^0.8.7; From 0ff56cb192e2787ecf7395bc56f1f2d692db41f3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:38:30 -0400 Subject: [PATCH 072/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index c04f05774c8..7c0f069c783 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: +// SPDX-License-Identifier: MIT License Modern Variant pragma solidity ^0.8.7; From d9da03f781704b465377d0b088b46d5aac65645d Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 15:45:38 -0400 Subject: [PATCH 073/141] Update SafeMath.sol --- contracts/token/ERC20/SafeMath.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/token/ERC20/SafeMath.sol b/contracts/token/ERC20/SafeMath.sol index 112eed1a8e6..806ce8f97ea 100644 --- a/contracts/token/ERC20/SafeMath.sol +++ b/contracts/token/ERC20/SafeMath.sol @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.0; +pragma solidity ^0.8.7; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, @@ -19,11 +19,12 @@ library SafeMath { * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { - unchecked { + + unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); - } + } } /** From 0a1b0c8e8c4c172fb253fe71e351b9aef5b08989 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:20:05 -0400 Subject: [PATCH 074/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 32336861647..e2a82656501 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; @@ -10,7 +10,7 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ -contract ERC20 is ERC20Basic { +contract ERC20 { function allowance(address owner, address spender) public view returns (uint256); From a906110dfaa5345eebb7d1f5a7c17728a8e5cba3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:49:13 -0400 Subject: [PATCH 075/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 363 ++++++++++++++++++++++++++++++-- 1 file changed, 350 insertions(+), 13 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index e2a82656501..9011c39b433 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -10,17 +10,354 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ -contract ERC20 { - function allowance(address owner, address spender) - public view returns (uint256); - - function transferFrom(address from, address to, uint256 value) - public returns (bool); - - function approve(address spender, uint256 value) public returns (bool); - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); + + +// File: @openzeppelin/contracts/utils/Context.sol + +/** + * @dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. + */ +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + + mapping(address => mapping(address => uint256)) private _allowances; + + uint256 private _totalSupply; + + string private _name; + string private _symbol; + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + _beforeTokenTransfer(sender, recipient, amount); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + _afterTokenTransfer(sender, recipient, amount); + } + + /** @dev Creates `amount` tokens and assigns them to `account`, increasing + * the total supply. + * + * Emits a {Transfer} event with `from` set to the zero address. + * + * Requirements: + * + * - `account` cannot be the zero address. + */ + function _mint(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: mint to the zero address"); + + _beforeTokenTransfer(address(0), account, amount); + + _totalSupply += amount; + _balances[account] += amount; + emit Transfer(address(0), account, amount); + + _afterTokenTransfer(address(0), account, amount); + } + + /** + * @dev Destroys `amount` tokens from `account`, reducing the + * total supply. + * + * Emits a {Transfer} event with `to` set to the zero address. + * + * Requirements: + * + * - `account` cannot be the zero address. + * - `account` must have at least `amount` tokens. + */ + function _burn(address account, uint256 amount) internal virtual { + require(account != address(0), "ERC20: burn from the zero address"); + + _beforeTokenTransfer(account, address(0), amount); + + uint256 accountBalance = _balances[account]; + require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); + unchecked { + _balances[account] = accountBalance - amount; + } + _totalSupply -= amount; + + emit Transfer(account, address(0), amount); + + _afterTokenTransfer(account, address(0), amount); + } + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + /** + * @dev Hook that is called before any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens + * will be transferred to `to`. + * - when `from` is zero, `amount` tokens will be minted for `to`. + * - when `to` is zero, `amount` of ``from``'s tokens will be burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _beforeTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} + + /** + * @dev Hook that is called after any transfer of tokens. This includes + * minting and burning. + * + * Calling conditions: + * + * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens + * has been transferred to `to`. + * - when `from` is zero, `amount` tokens have been minted for `to`. + * - when `to` is zero, `amount` of ``from``'s tokens have been burned. + * - `from` and `to` are never both zero. + * + * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. + */ + function _afterTokenTransfer( + address from, + address to, + uint256 amount + ) internal virtual {} } From 2a6b847309de453a5c0ead86c1cc06bba8963a32 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:49:57 -0400 Subject: [PATCH 076/141] Update IERC20.sol --- contracts/token/ERC20/IERC20.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 28d73cbf8ab..1ed2a0c36d8 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; /** * @dev Interface of the ERC20 standard as defined in the EIP. From 10bf77342d7a8ea52cd09782dd6d9367f39779f2 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:52:06 -0400 Subject: [PATCH 077/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index a9394c0234e..6e164ee3eb2 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,7 +1,8 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; @@ -9,7 +10,7 @@ import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contr * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ -contract BasicToken is ERC20Basic { +contract BasicToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; From b214d22d94e9fd9aa642cc69e0719e89961a3016 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:54:40 -0400 Subject: [PATCH 078/141] Update Ownable.sol --- contracts/ownership/Ownable.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index d3c78b8d83f..aa9cce82dd3 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -1,4 +1,6 @@ -pragma solidity ^0.8.4; +// SPDX-License-Identifier: MIT License Modern Variant + +pragma solidity ^0.8.7; /** From 84d40ec9068877e9c2fd81dd4d9417d7f16be182 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:57:41 -0400 Subject: [PATCH 079/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 9011c39b433..34bd66ba119 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -2,19 +2,15 @@ pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; + /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 - */ - - -// File: @openzeppelin/contracts/utils/Context.sol - -/** + File: @openzeppelin/contracts/utils/Context.sol * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means @@ -39,6 +35,7 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ + contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; From c4b10d5e526309297248272f74dd8323c9e2ca73 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:06:32 -0400 Subject: [PATCH 080/141] Update IndividuallyCappedCrowdsale.sol --- .../crowdsale/validation/IndividuallyCappedCrowdsale.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 821449302f7..b4d07b2a7f5 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -1,4 +1,6 @@ -pragma solidity ^0.8.4; +// SPDX-License-Identifier: MIT License Modern Variant + +pragma solidity ^0.8.7; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From 0a4f9310f780e99c0374a6fc447a1543bd3f4527 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:16:22 -0400 Subject: [PATCH 081/141] Update Ownable.sol --- contracts/ownership/Ownable.sol | 110 ++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index aa9cce82dd3..74f1c936bae 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -2,54 +2,70 @@ pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; /** - * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. */ -contract Ownable { - address public owner; - - - event OwnershipRenounced(address indexed previousOwner); - event OwnershipTransferred( - address indexed previousOwner, - address indexed newOwner - ); - - - /** - * @dev The Ownable constructor sets the original `owner` of the contract to the sender - * account. - */ - constructor() public { - owner = msg.sender; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(msg.sender == owner); - _; - } - - /** - * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param newOwner The address to transfer ownership to. - */ - function transferOwnership(address newOwner) public onlyOwner { - require(newOwner != address(0)); - emit OwnershipTransferred(owner, newOwner); - owner = newOwner; - } - - /** - * @dev Allows the current owner to relinquish control of the contract. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); - owner = address(0); - } +abstract contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor() { + _setOwner(_msgSender()); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view virtual returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(owner() == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + _setOwner(address(0)); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + _setOwner(newOwner); + } + + function _setOwner(address newOwner) private { + address oldOwner = _owner; + _owner = newOwner; + emit OwnershipTransferred(oldOwner, newOwner); + } } From 0f8b01d5593b9aa9d75b442944fdf0207f25e413 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:20:55 -0400 Subject: [PATCH 082/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 34bd66ba119..b3d7823065a 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -7,10 +7,9 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -/** - * @title ERC20 interface +/** title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 - File: @openzeppelin/contracts/utils/Context.sol + * openzeppelin/contracts/utils/Context.sol * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means From ce02dc500bb68005bc4ebec830ad2c052b92dd07 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:26:53 -0400 Subject: [PATCH 083/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 83a52c1c4f3..9451fa65292 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,6 +1,6 @@ -// SPDX-License-Identifier: MIT +// SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; /** * @title ERC20Basic From 6725c52bff5df75af92e398101871b15d9860c67 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:34:51 -0400 Subject: [PATCH 084/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 6e164ee3eb2..b2064662cbb 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; @@ -10,7 +11,7 @@ import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contr * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ -contract BasicToken is ERC20 { +contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; From e721b974ba9ee3cd2d571782c6e53ae538e0a029 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 20:24:12 -0400 Subject: [PATCH 085/141] Update Ownable.sol --- contracts/ownership/Ownable.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 74f1c936bae..2511c2839db 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; /** - * @dev Contract module which provides a basic access control mechanism, where + * dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * From b66499478b443161fd03c770e7501a60736664f2 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 21:09:46 -0400 Subject: [PATCH 086/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 54 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 9451fa65292..9bb2e3e1d61 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -2,14 +2,52 @@ pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/179 + * @title Basic token + * @dev Basic version of StandardToken, with no allowances. */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address who) public view returns (uint256); - function transfer(address to, uint256 value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); +contract BasicToken is ERC20Basic { + using SafeMath for uint256; + + mapping(address => uint256) balances; + + uint256 totalSupply_; + + /** + * @dev total number of tokens in existence + */ + function totalSupply() public view returns (uint256) { + return totalSupply_; + } + + /** + * @dev transfer token for a specified address + * @param _to The address to transfer to. + * @param _value The amount to be transferred. + */ + function transfer(address _to, uint256 _value) public returns (bool) { + require(_to != address(0)); + require(_value <= balances[msg.sender]); + + balances[msg.sender] = balances[msg.sender].sub(_value); + balances[_to] = balances[_to].add(_value); + emit Transfer(msg.sender, _to, _value); + return true; + } + + /** + * @dev Gets the balance of the specified address. + * @param _owner The address to query the the balance of. + * @return An uint256 representing the amount owned by the passed address. + */ + function balanceOf(address _owner) public view returns (uint256) { + return balances[_owner]; + } + } From ead8a76d9ed6ef72c9dd57fff12cb78e598aeea2 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 21:10:57 -0400 Subject: [PATCH 087/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index b2064662cbb..9bb2e3e1d61 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -3,10 +3,11 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; - - /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. From acfd8a2a6b6c75915b4aa685a9861af149d100d1 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 21:13:04 -0400 Subject: [PATCH 088/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 55 +++++----------------------- 1 file changed, 9 insertions(+), 46 deletions(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 9bb2e3e1d61..eac3417c247 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -2,52 +2,15 @@ pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; /** - * @title Basic token - * @dev Basic version of StandardToken, with no allowances. + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/179 */ -contract BasicToken is ERC20Basic { - using SafeMath for uint256; - - mapping(address => uint256) balances; - - uint256 totalSupply_; - - /** - * @dev total number of tokens in existence - */ - function totalSupply() public view returns (uint256) { - return totalSupply_; - } - - /** - * @dev transfer token for a specified address - * @param _to The address to transfer to. - * @param _value The amount to be transferred. - */ - function transfer(address _to, uint256 _value) public returns (bool) { - require(_to != address(0)); - require(_value <= balances[msg.sender]); - - balances[msg.sender] = balances[msg.sender].sub(_value); - balances[_to] = balances[_to].add(_value); - emit Transfer(msg.sender, _to, _value); - return true; - } - - /** - * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. - * @return An uint256 representing the amount owned by the passed address. - */ - function balanceOf(address _owner) public view returns (uint256) { - return balances[_owner]; - } - +contract ERC20Basic { + function totalSupply() public view returns (uint256); + function balanceOf(address who) public view returns (uint256); + function transfer(address to, uint256 value) public returns (bool); + event Transfer(address indexed from, address indexed to, uint256 value); } +© 2021 GitHub, Inc. From e0ea43a076f9d95b2ac0337cf78e70a421abb2fa Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 21:33:16 -0400 Subject: [PATCH 089/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index eac3417c247..f86a2b1cd66 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.7; /** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/179 + * title ERC20Basic + * dev Simpler version of ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); From 37f4bfb361bea683254a5d5bdc8bbf3775f2a1cc Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 23:17:14 -0400 Subject: [PATCH 090/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 94 ++++++++++++++++++---------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 9bb2e3e1d61..82a13322aa6 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,53 +1,83 @@ -// SPDX-License-Identifier: MIT License Modern Variant +// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; -/** - * @title Basic token - * @dev Basic version of StandardToken, with no allowances. - */ -contract BasicToken is ERC20Basic { - using SafeMath for uint256; - - mapping(address => uint256) balances; - uint256 totalSupply_; +contract BasicToken { + /* *This creates an array with all balancesOf */ + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + + event Transfer(address indexed from, address indexed to, uint256 value); + /** - * @dev total number of tokens in existence + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + + /** + * dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { - return totalSupply_; + return _totalSupply; } - /** - * @dev transfer token for a specified address - * @param _to The address to transfer to. - * @param _value The amount to be transferred. - */ - function transfer(address _to, uint256 _value) public returns (bool) { - require(_to != address(0)); - require(_value <= balances[msg.sender]); + - balances[msg.sender] = balances[msg.sender].sub(_value); - balances[_to] = balances[_to].add(_value); - emit Transfer(msg.sender, _to, _value); +/** + * @dev Transfer tokens from one address to another + * @param _from address The address which you want to send tokens from + * @param _to address The address which you want to transfer to + * @param _value uint256 the amount of tokens to be transferred + */ + function transferFrom( + address _from, + address _to, + uint256 _value + ) + public returns (bool){ + require(_to != address(0)); + + emit Transfer(_from, _to, _value); return true; } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address owner) public view returns (uint256) { + return _balances[owner]; + } - /** - * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. - * @return An uint256 representing the amount owned by the passed address. - */ - function balanceOf(address _owner) public view returns (uint256) { - return balances[_owner]; } -} + + + + + + + + From e3a0f91d7147ffe42d68f03a73354c95c775df9e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 23:20:50 -0400 Subject: [PATCH 091/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index f86a2b1cd66..b5ea1a3be6f 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -13,4 +13,4 @@ contract ERC20Basic { function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } -© 2021 GitHub, Inc. + From c2909efd9f433472b3fbef9b7fb96f8e9ddd986c Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 23:42:52 -0400 Subject: [PATCH 092/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 271 ++++++++++++++++++++++++++- 1 file changed, 261 insertions(+), 10 deletions(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index b5ea1a3be6f..b79b8f58f32 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -2,15 +2,266 @@ pragma solidity ^0.8.7; -/** - * title ERC20Basic - * dev Simpler version of ERC20 interface - * dev see https://github.com/ethereum/EIPs/issues/179 +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; + + + +/** title ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address who) public view returns (uint256); - function transfer(address to, uint256 value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + } + + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } +} From 7a8b637e628cbf2952274d4d9f5116b0aefe0a8d Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 1 Sep 2021 23:45:15 -0400 Subject: [PATCH 093/141] Delete ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 267 --------------------------- 1 file changed, 267 deletions(-) delete mode 100644 contracts/token/ERC20/ERC20Basic.sol diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol deleted file mode 100644 index b79b8f58f32..00000000000 --- a/contracts/token/ERC20/ERC20Basic.sol +++ /dev/null @@ -1,267 +0,0 @@ -// SPDX-License-Identifier: MIT License Modern Variant - -pragma solidity ^0.8.7; - -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; - - - -/** title ERC20 interface - * dev see https://github.com/ethereum/EIPs/issues/20 - * openzeppelin/contracts/utils/Context.sol - * dev Implementation of the {IERC20} interface. - * - * This implementation is agnostic to the way tokens are created. This means - * that a supply mechanism has to be added in a derived contract using {_mint}. - * For a generic mechanism see {ERC20PresetMinterPauser}. - * - * TIP: For a detailed writeup see our guide - * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How - * to implement supply mechanisms]. - * - * We have followed general OpenZeppelin Contracts guidelines: functions revert - * instead returning `false` on failure. This behavior is nonetheless - * conventional and does not conflict with the expectations of ERC20 - * applications. - * - * Additionally, an {Approval} event is emitted on calls to {transferFrom}. - * This allows applications to reconstruct the allowance for all accounts just - * by listening to said events. Other implementations of the EIP may not emit - * these events, as it isn't required by the specification. - * - * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} - * functions have been added to mitigate the well-known issues around setting - * allowances. See {IERC20-approve}. - */ - -contract ERC20 is Context, IERC20, IERC20Metadata { - mapping(address => uint256) private _balances; - mapping(address => mapping(address => uint256)) private _allowances; - - string private _name; - string private _symbol; - uint8 public _decimals; - uint256 private _totalSupply; - /** - * @dev Sets the values for {name} and {symbol}. - * - * The default value of {decimals} is 18. To select a different value for - * {decimals} you should overload it. - * - * All two of these values are immutable: they can only be set once during - * construction. - */ - constructor(string memory name_, string memory symbol_) { - _name = name_; - _symbol = symbol_; - } - - /** - * @dev Returns the name of the token. - */ - function name() public view virtual override returns (string memory) { - return _name; - } - - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() public view virtual override returns (string memory) { - return _symbol; - } - - /** - * @dev Returns the number of decimals used to get its user representation. - * For example, if `decimals` equals `2`, a balance of `505` tokens should - * be displayed to a user as `5.05` (`505 / 10 ** 2`). - * - * Tokens usually opt for a value of 18, imitating the relationship between - * Ether and Wei. This is the value {ERC20} uses, unless this function is - * overridden; - * - * NOTE: This information is only used for _display_ purposes: it in - * no way affects any of the arithmetic of the contract, including - * {IERC20-balanceOf} and {IERC20-transfer}. - */ - function decimals() public view virtual override returns (uint8) { - return 18; - } - - /** - * @dev See {IERC20-totalSupply}. - */ - function totalSupply() public view virtual override returns (uint256) { - return _totalSupply; - } - - /** - * @dev See {IERC20-balanceOf}. - */ - function balanceOf(address account) public view virtual override returns (uint256) { - return _balances[account]; - } - - /** - * @dev See {IERC20-transfer}. - * - * Requirements: - * - * - `recipient` cannot be the zero address. - * - the caller must have a balance of at least `amount`. - */ - function transfer(address recipient, uint256 amount) public virtual override returns (bool) { - _transfer(_msgSender(), recipient, amount); - return true; - } - - /** - * @dev See {IERC20-allowance}. - */ - function allowance(address owner, address spender) public view virtual override returns (uint256) { - return _allowances[owner][spender]; - } - - /** - * @dev See {IERC20-approve}. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function approve(address spender, uint256 amount) public virtual override returns (bool) { - _approve(_msgSender(), spender, amount); - return true; - } - - /** - * @dev See {IERC20-transferFrom}. - * - * Emits an {Approval} event indicating the updated allowance. This is not - * required by the EIP. See the note at the beginning of {ERC20}. - * - * Requirements: - * - * - `sender` and `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - * - the caller must have allowance for ``sender``'s tokens of at least - * `amount`. - */ - function transferFrom( - address sender, - address recipient, - uint256 amount - ) public virtual override returns (bool) { - _transfer(sender, recipient, amount); - - uint256 currentAllowance = _allowances[sender][_msgSender()]; - require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); - unchecked { - _approve(sender, _msgSender(), currentAllowance - amount); - } - - return true; - } - - /** - * @dev Atomically increases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); - return true; - } - - /** - * @dev Atomically decreases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - * - `spender` must have allowance for the caller of at least - * `subtractedValue`. - */ - function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { - uint256 currentAllowance = _allowances[_msgSender()][spender]; - require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); - unchecked { - _approve(_msgSender(), spender, currentAllowance - subtractedValue); - } - - return true; - } - - /** - * @dev Moves `amount` of tokens from `sender` to `recipient`. - * - * This internal function is equivalent to {transfer}, and can be used to - * e.g. implement automatic token fees, slashing mechanisms, etc. - * - * Emits a {Transfer} event. - * - * Requirements: - * - * - `sender` cannot be the zero address. - * - `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - */ - function _transfer( - address sender, - address recipient, - uint256 amount - ) internal virtual { - require(sender != address(0), "ERC20: transfer from the zero address"); - require(recipient != address(0), "ERC20: transfer to the zero address"); - - uint256 senderBalance = _balances[sender]; - require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); - unchecked { - _balances[sender] = senderBalance - amount; - } - _balances[recipient] += amount; - - emit Transfer(sender, recipient, amount); - - } - - - /** - * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. - * - * This internal function is equivalent to `approve`, and can be used to - * e.g. set automatic allowances for certain subsystems, etc. - * - * Emits an {Approval} event. - * - * Requirements: - * - * - `owner` cannot be the zero address. - * - `spender` cannot be the zero address. - */ - function _approve( - address owner, - address spender, - uint256 amount - ) internal virtual { - require(owner != address(0), "ERC20: approve from the zero address"); - require(spender != address(0), "ERC20: approve to the zero address"); - - _allowances[owner][spender] = amount; - emit Approval(owner, spender, amount); - } -} From 687711b6c1cf2160e4959c46c4daec13ef7f41d3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:51:13 -0400 Subject: [PATCH 094/141] Update FinalizableCrowdsale.sol --- .../crowdsale/distribution/FinalizableCrowdsale.sol | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index 74b45d16186..aca51a1229c 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -1,8 +1,10 @@ -pragma solidity ^0.4.23; +// SPDX-License-Identifier: MIT -import "../../math/SafeMath.sol"; -import "../../ownership/Ownable.sol"; -import "../validation/TimedCrowdsale.sol"; +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/validation/TimedCrowdsale.sol"; /** From 8d593884cfd1a4874aee785d1ca2b67ef15a56cf Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:52:02 -0400 Subject: [PATCH 095/141] Update TimedCrowdsale.sol --- contracts/crowdsale/validation/TimedCrowdsale.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 4cf0cea32d1..f39903812df 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -1,11 +1,13 @@ -pragma solidity ^0.8.4; +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.7; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.soll"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; /** - * @title TimedCrowdsale + * title TimedCrowdsale * @dev Crowdsale accepting contributions only within a time frame. */ contract TimedCrowdsale is Crowdsale { From ce86cc8838ddc9001f85599f7eceb29e92c4ce65 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:53:19 -0400 Subject: [PATCH 096/141] Delete Ownable.sol --- contracts/ownership/Ownable.sol | 71 --------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 contracts/ownership/Ownable.sol diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol deleted file mode 100644 index 2511c2839db..00000000000 --- a/contracts/ownership/Ownable.sol +++ /dev/null @@ -1,71 +0,0 @@ -// SPDX-License-Identifier: MIT License Modern Variant - -pragma solidity ^0.8.7; - -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; - -/** - * dev Contract module which provides a basic access control mechanism, where - * there is an account (an owner) that can be granted exclusive access to - * specific functions. - * - * By default, the owner account will be the one that deploys the contract. This - * can later be changed with {transferOwnership}. - * - * This module is used through inheritance. It will make available the modifier - * `onlyOwner`, which can be applied to your functions to restrict their use to - * the owner. - */ -abstract contract Ownable is Context { - address private _owner; - - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - - /** - * @dev Initializes the contract setting the deployer as the initial owner. - */ - constructor() { - _setOwner(_msgSender()); - } - - /** - * @dev Returns the address of the current owner. - */ - function owner() public view virtual returns (address) { - return _owner; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(owner() == _msgSender(), "Ownable: caller is not the owner"); - _; - } - - /** - * @dev Leaves the contract without owner. It will not be possible to call - * `onlyOwner` functions anymore. Can only be called by the current owner. - * - * NOTE: Renouncing ownership will leave the contract without an owner, - * thereby removing any functionality that is only available to the owner. - */ - function renounceOwnership() public virtual onlyOwner { - _setOwner(address(0)); - } - - /** - * @dev Transfers ownership of the contract to a new account (`newOwner`). - * Can only be called by the current owner. - */ - function transferOwnership(address newOwner) public virtual onlyOwner { - require(newOwner != address(0), "Ownable: new owner is the zero address"); - _setOwner(newOwner); - } - - function _setOwner(address newOwner) private { - address oldOwner = _owner; - _owner = newOwner; - emit OwnershipTransferred(oldOwner, newOwner); - } -} From bbec66dc355eb77d1f7edb7e0a58cb08a8afdd99 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:54:02 -0400 Subject: [PATCH 097/141] Create Ownable.sol --- contracts/ownership/Ownable.sol | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 contracts/ownership/Ownable.sol diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol new file mode 100644 index 00000000000..2511c2839db --- /dev/null +++ b/contracts/ownership/Ownable.sol @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: MIT License Modern Variant + +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; + +/** + * dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +abstract contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor() { + _setOwner(_msgSender()); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view virtual returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(owner() == _msgSender(), "Ownable: caller is not the owner"); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + _setOwner(address(0)); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), "Ownable: new owner is the zero address"); + _setOwner(newOwner); + } + + function _setOwner(address newOwner) private { + address oldOwner = _owner; + _owner = newOwner; + emit OwnershipTransferred(oldOwner, newOwner); + } +} From 1838f760208dab28aca4358b633278c87869e0b2 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:54:51 -0400 Subject: [PATCH 098/141] Delete BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 83 ---------------------------- 1 file changed, 83 deletions(-) delete mode 100644 contracts/token/ERC20/BasicToken.sol diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol deleted file mode 100644 index 82a13322aa6..00000000000 --- a/contracts/token/ERC20/BasicToken.sol +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED - -pragma solidity ^0.8.7; - -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; - - -contract BasicToken { - /* *This creates an array with all balancesOf */ - mapping(address => uint256) private _balances; - mapping(address => mapping(address => uint256)) private _allowances; - - - string private _name; - string private _symbol; - uint8 public _decimals; - uint256 private _totalSupply; - - event Transfer(address indexed from, address indexed to, uint256 value); - - /** - * @dev Sets the values for {name} and {symbol}. - * - * The default value of {decimals} is 18. To select a different value for - * {decimals} you should overload it. - * - * All two of these values are immutable: they can only be set once during - * construction. - */ - constructor(string memory name_, string memory symbol_) { - _name = name_; - _symbol = symbol_; - } - - - /** - * dev total number of tokens in existence - */ - function totalSupply() public view returns (uint256) { - return _totalSupply; - } - - - -/** - * @dev Transfer tokens from one address to another - * @param _from address The address which you want to send tokens from - * @param _to address The address which you want to transfer to - * @param _value uint256 the amount of tokens to be transferred - */ - function transferFrom( - address _from, - address _to, - uint256 _value - ) - public returns (bool){ - require(_to != address(0)); - - emit Transfer(_from, _to, _value); - return true; - } - - /** - * @dev See {IERC20-balanceOf}. - */ - function balanceOf(address owner) public view returns (uint256) { - return _balances[owner]; - } - - } - - - - - - - - - From 80d56630dabe687ca15fc1154cc3c373991893a3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:55:17 -0400 Subject: [PATCH 099/141] Create BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 contracts/token/ERC20/BasicToken.sol diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol new file mode 100644 index 00000000000..d7e5ea62ab7 --- /dev/null +++ b/contracts/token/ERC20/BasicToken.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: UNLICENSED + +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; + + +contract BasicToken { + /* *This creates an array with all balancesOf */ + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + + /** + * dev total number of tokens in existence + */ + function totalSupply() public view returns (uint256) { + return _totalSupply; + } + + + +/** + * @dev Transfer tokens from one address to another + * @param _from address The address which you want to send tokens from + * @param _to address The address which you want to transfer to + * @param _value uint256 the amount of tokens to be transferred + */ + function transferFrom( + address _from, + address _to, + uint256 _value + ) + public returns (bool){ + require(_to != address(0)); + + emit Transfer(_from, _to, _value); + return true; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address owner) public view returns (uint256) { + return _balances[owner]; + } + + } From f09646f147cd7c37bd5a0622bc47c8435352d779 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 18:00:28 -0400 Subject: [PATCH 100/141] Update TimedCrowdsale.sol --- contracts/crowdsale/validation/TimedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index f39903812df..a00c3aa5f73 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.7; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.soll"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From e8dcea3a0c6a9576d5ac814cf1e68514b11f2e6e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 18:02:38 -0400 Subject: [PATCH 101/141] Delete TimedCrowdsale.sol --- .../crowdsale/validation/TimedCrowdsale.sol | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 contracts/crowdsale/validation/TimedCrowdsale.sol diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol deleted file mode 100644 index a00c3aa5f73..00000000000 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.7; - -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; - - -/** - * title TimedCrowdsale - * @dev Crowdsale accepting contributions only within a time frame. - */ -contract TimedCrowdsale is Crowdsale { - using SafeMath for uint256; - - uint256 public openingTime; - uint256 public closingTime; - - /** - * @dev Reverts if not in crowdsale time range. - */ - modifier onlyWhileOpen { - // solium-disable-next-line security/no-block-members - require(block.timestamp >= openingTime && block.timestamp <= closingTime); - _; - } - - /** - * @dev Constructor, takes crowdsale opening and closing times. - * @param _openingTime Crowdsale opening time - * @param _closingTime Crowdsale closing time - */ - constructor(uint256 _openingTime, uint256 _closingTime) public { - // solium-disable-next-line security/no-block-members - require(_openingTime >= block.timestamp); - require(_closingTime >= _openingTime); - - openingTime = _openingTime; - closingTime = _closingTime; - } - - /** - * @dev Checks whether the period in which the crowdsale is open has already elapsed. - * @return Whether crowdsale period has elapsed - */ - function hasClosed() public view returns (bool) { - // solium-disable-next-line security/no-block-members - return block.timestamp > closingTime; - } - - /** - * @dev Extend parent behavior requiring to be within contributing period - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed - */ - function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount - ) - internal - onlyWhileOpen - { - super._preValidatePurchase(_beneficiary, _weiAmount); - } - -} From 0bbe556718ca35031ca0a49c9702ca6c187c2713 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 18:03:02 -0400 Subject: [PATCH 102/141] Create TimedCrowdsale.sol --- .../crowdsale/validation/TimedCrowdsale.sol | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 contracts/crowdsale/validation/TimedCrowdsale.sol diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol new file mode 100644 index 00000000000..a00c3aa5f73 --- /dev/null +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.7; + +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; + + +/** + * title TimedCrowdsale + * @dev Crowdsale accepting contributions only within a time frame. + */ +contract TimedCrowdsale is Crowdsale { + using SafeMath for uint256; + + uint256 public openingTime; + uint256 public closingTime; + + /** + * @dev Reverts if not in crowdsale time range. + */ + modifier onlyWhileOpen { + // solium-disable-next-line security/no-block-members + require(block.timestamp >= openingTime && block.timestamp <= closingTime); + _; + } + + /** + * @dev Constructor, takes crowdsale opening and closing times. + * @param _openingTime Crowdsale opening time + * @param _closingTime Crowdsale closing time + */ + constructor(uint256 _openingTime, uint256 _closingTime) public { + // solium-disable-next-line security/no-block-members + require(_openingTime >= block.timestamp); + require(_closingTime >= _openingTime); + + openingTime = _openingTime; + closingTime = _closingTime; + } + + /** + * @dev Checks whether the period in which the crowdsale is open has already elapsed. + * @return Whether crowdsale period has elapsed + */ + function hasClosed() public view returns (bool) { + // solium-disable-next-line security/no-block-members + return block.timestamp > closingTime; + } + + /** + * @dev Extend parent behavior requiring to be within contributing period + * @param _beneficiary Token purchaser + * @param _weiAmount Amount of wei contributed + */ + function _preValidatePurchase( + address _beneficiary, + uint256 _weiAmount + ) + internal + onlyWhileOpen + { + super._preValidatePurchase(_beneficiary, _weiAmount); + } + +} From 6ab01b4b89a10d8a878d208b48dfb320752b1c95 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 18:13:40 -0400 Subject: [PATCH 103/141] Delete FinalizableCrowdsale.sol --- .../distribution/FinalizableCrowdsale.sol | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 contracts/crowdsale/distribution/FinalizableCrowdsale.sol diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol deleted file mode 100644 index aca51a1229c..00000000000 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.7; - -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/validation/TimedCrowdsale.sol"; - - -/** - * @title FinalizableCrowdsale - * @dev Extension of Crowdsale where an owner can do extra work - * after finishing. - */ -contract FinalizableCrowdsale is TimedCrowdsale, Ownable { - using SafeMath for uint256; - - bool public isFinalized = false; - - event Finalized(); - - /** - * @dev Must be called after crowdsale ends, to do some extra finalization - * work. Calls the contract's finalization function. - */ - function finalize() onlyOwner public { - require(!isFinalized); - require(hasClosed()); - - finalization(); - emit Finalized(); - - isFinalized = true; - } - - /** - * @dev Can be overridden to add finalization logic. The overriding function - * should call super.finalization() to ensure the chain of finalization is - * executed entirely. - */ - function finalization() internal { - } - -} From fe5111442d8cad1f0e804f6573530f21f78305cf Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 18:15:00 -0400 Subject: [PATCH 104/141] Create FinalizableCrowdsale.sol --- .../distribution/FinalizableCrowdsale.sol | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 contracts/crowdsale/distribution/FinalizableCrowdsale.sol diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol new file mode 100644 index 00000000000..b9e8e72faf5 --- /dev/null +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/validation/TimedCrowdsale.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; + +/** + * title FinalizableCrowdsale + * dev Extension of Crowdsale where an owner can do extra work after finishing. + */ +contract FinalizableCrowdsale is TimedCrowdsale, Ownable { + bool public isFinalized = false; + event Finalized(); + using SafeMath for uint256; + + /** + * @dev Must be called after crowdsale ends, to do some extra finalization + * work. Calls the contract's finalization function. + */ + function finalize() onlyOwner public { + require(!isFinalized); + require(hasClosed()); + + finalization(); + emit Finalized(); + + isFinalized = true; + } + + /** + * @dev Can be overridden to add finalization logic. The overriding function + * should call super.finalization() to ensure the chain of finalization is + * executed entirely. + */ + function finalization() internal { + } + +} From 6f031cb0046608692c6acf49a33b43de80139043 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 19:55:44 -0400 Subject: [PATCH 105/141] Create ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 267 +++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 contracts/token/ERC20/ERC20Basic.sol diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol new file mode 100644 index 00000000000..b79b8f58f32 --- /dev/null +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: MIT License Modern Variant + +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; + + + +/** title ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. + */ + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + } + + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } +} From 43f9ab0d4eeaca1138d9015b6cfe1849b32f592c Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 19:57:16 -0400 Subject: [PATCH 106/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index d7e5ea62ab7..b46d65f5276 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -7,9 +7,9 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; - -contract BasicToken { +contract BasicToken is ERC20Basic { /* *This creates an array with all balancesOf */ mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; From 56abc32fed76642c6fb83b3046f9b5442fa354e5 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 19:59:13 -0400 Subject: [PATCH 107/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index b79b8f58f32..86c4a24087f 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.7; +pragma solidity ^0.4.23; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; From 07c3e323a7dbb469764f3b09fe4d9261e84a52dd Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 20:07:09 -0400 Subject: [PATCH 108/141] Update ERC20Basic.sol --- contracts/token/ERC20/ERC20Basic.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/ERC20Basic.sol b/contracts/token/ERC20/ERC20Basic.sol index 86c4a24087f..b79b8f58f32 100644 --- a/contracts/token/ERC20/ERC20Basic.sol +++ b/contracts/token/ERC20/ERC20Basic.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.4.23; +pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; From 0c1ccd710deb044dd526d7486e70593b7fce5654 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 20:10:41 -0400 Subject: [PATCH 109/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 275 ++++++++++++++++++++++++++- 1 file changed, 272 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index b46d65f5276..0df9e764117 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,15 +1,16 @@ // SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: UNLICENSED + pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; -contract BasicToken is ERC20Basic { + +contract BasicToken { /* *This creates an array with all balancesOf */ mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; @@ -72,3 +73,271 @@ contract BasicToken is ERC20Basic { } } + + +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; + + + +/** title ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. + */ + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + } + + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } +} From a1fc9b155ac3ed3cbbbac946dd76edc2c82507b8 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 20:10:58 -0400 Subject: [PATCH 110/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 0df9e764117..4f699ab90a4 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -1,7 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -// SPDX-License-Identifier: UNLICENSED - pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; From f236d0413a25bcc316a3fbe6b13abd2f7b9ec509 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 21:28:08 -0400 Subject: [PATCH 111/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 412 ++++++++++++++++++------ 1 file changed, 311 insertions(+), 101 deletions(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index 7c0f069c783..dd4a3903e89 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -1,24 +1,51 @@ -// SPDX-License-Identifier: MIT License Modern Variant +// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; -/** - * @title Standard ERC20 token - * - * @dev Implementation of the basic standard token. - * @dev https://github.com/ethereum/EIPs/issues/20 - * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol - */ -contract StandardToken is ERC20, BasicToken { - - mapping (address => mapping (address => uint256)) internal allowed; +contract BasicToken { + /* *This creates an array with all balancesOf */ + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + + event Transfer(address indexed from, address indexed to, uint256 value); + + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + + /** + * dev total number of tokens in existence + */ + function totalSupply() public view returns (uint256) { + return _totalSupply; + } + - /** +/** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to @@ -29,101 +56,284 @@ contract StandardToken is ERC20, BasicToken { address _to, uint256 _value ) - public - returns (bool) - { + public returns (bool){ require(_to != address(0)); - require(_value <= balances[_from]); - require(_value <= allowed[_from][msg.sender]); - - balances[_from] = balances[_from].sub(_value); - balances[_to] = balances[_to].add(_value); - allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); + emit Transfer(_from, _to, _value); return true; } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address owner) public view returns (uint256) { + return _balances[owner]; + } - /** - * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. - * - * Beware that changing an allowance with this method brings the risk that someone may use both the old - * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this - * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: - * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * @param _spender The address which will spend the funds. - * @param _value The amount of tokens to be spent. - */ - function approve(address _spender, uint256 _value) public returns (bool) { - allowed[msg.sender][_spender] = _value; - emit Approval(msg.sender, _spender, _value); - return true; } - /** - * @dev Function to check the amount of tokens that an owner allowed to a spender. - * @param _owner address The address which owns the funds. - * @param _spender address The address which will spend the funds. - * @return A uint256 specifying the amount of tokens still available for the spender. - */ - function allowance( - address _owner, - address _spender - ) - public - view - returns (uint256) - { - return allowed[_owner][_spender]; - } + +pragma solidity ^0.8.7; + +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; - /** - * @dev Increase the amount of tokens that an owner allowed to a spender. - * - * approve should be called when allowed[_spender] == 0. To increment - * allowed value is better to use this function to avoid 2 calls (and wait until - * the first transaction is mined) - * From MonolithDAO Token.sol - * @param _spender The address which will spend the funds. - * @param _addedValue The amount of tokens to increase the allowance by. - */ - function increaseApproval( - address _spender, - uint _addedValue - ) - public - returns (bool) - { - allowed[msg.sender][_spender] = ( - allowed[msg.sender][_spender].add(_addedValue)); - emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); - return true; - } - /** - * @dev Decrease the amount of tokens that an owner allowed to a spender. - * - * approve should be called when allowed[_spender] == 0. To decrement - * allowed value is better to use this function to avoid 2 calls (and wait until - * the first transaction is mined) - * From MonolithDAO Token.sol - * @param _spender The address which will spend the funds. - * @param _subtractedValue The amount of tokens to decrease the allowance by. - */ - function decreaseApproval( - address _spender, - uint _subtractedValue - ) - public - returns (bool) - { - uint oldValue = allowed[msg.sender][_spender]; - if (_subtractedValue > oldValue) { - allowed[msg.sender][_spender] = 0; - } else { - allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); - } - emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); - return true; - } +/** title ERC20 interface + * dev see https://github.com/ethereum/EIPs/issues/20 + * openzeppelin/contracts/utils/Context.sol + * dev Implementation of the {IERC20} interface. + * + * This implementation is agnostic to the way tokens are created. This means + * that a supply mechanism has to be added in a derived contract using {_mint}. + * For a generic mechanism see {ERC20PresetMinterPauser}. + * + * TIP: For a detailed writeup see our guide + * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How + * to implement supply mechanisms]. + * + * We have followed general OpenZeppelin Contracts guidelines: functions revert + * instead returning `false` on failure. This behavior is nonetheless + * conventional and does not conflict with the expectations of ERC20 + * applications. + * + * Additionally, an {Approval} event is emitted on calls to {transferFrom}. + * This allows applications to reconstruct the allowance for all accounts just + * by listening to said events. Other implementations of the EIP may not emit + * these events, as it isn't required by the specification. + * + * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} + * functions have been added to mitigate the well-known issues around setting + * allowances. See {IERC20-approve}. + */ + +contract ERC20 is Context, IERC20, IERC20Metadata { + mapping(address => uint256) private _balances; + mapping(address => mapping(address => uint256)) private _allowances; + + string private _name; + string private _symbol; + uint8 public _decimals; + uint256 private _totalSupply; + /** + * @dev Sets the values for {name} and {symbol}. + * + * The default value of {decimals} is 18. To select a different value for + * {decimals} you should overload it. + * + * All two of these values are immutable: they can only be set once during + * construction. + */ + constructor(string memory name_, string memory symbol_) { + _name = name_; + _symbol = symbol_; + } + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + /** + * @dev Returns the number of decimals used to get its user representation. + * For example, if `decimals` equals `2`, a balance of `505` tokens should + * be displayed to a user as `5.05` (`505 / 10 ** 2`). + * + * Tokens usually opt for a value of 18, imitating the relationship between + * Ether and Wei. This is the value {ERC20} uses, unless this function is + * overridden; + * + * NOTE: This information is only used for _display_ purposes: it in + * no way affects any of the arithmetic of the contract, including + * {IERC20-balanceOf} and {IERC20-transfer}. + */ + function decimals() public view virtual override returns (uint8) { + return 18; + } + + /** + * @dev See {IERC20-totalSupply}. + */ + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + /** + * @dev See {IERC20-balanceOf}. + */ + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account]; + } + + /** + * @dev See {IERC20-transfer}. + * + * Requirements: + * + * - `recipient` cannot be the zero address. + * - the caller must have a balance of at least `amount`. + */ + function transfer(address recipient, uint256 amount) public virtual override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + /** + * @dev See {IERC20-allowance}. + */ + function allowance(address owner, address spender) public view virtual override returns (uint256) { + return _allowances[owner][spender]; + } + + /** + * @dev See {IERC20-approve}. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function approve(address spender, uint256 amount) public virtual override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + /** + * @dev See {IERC20-transferFrom}. + * + * Emits an {Approval} event indicating the updated allowance. This is not + * required by the EIP. See the note at the beginning of {ERC20}. + * + * Requirements: + * + * - `sender` and `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + * - the caller must have allowance for ``sender``'s tokens of at least + * `amount`. + */ + function transferFrom( + address sender, + address recipient, + uint256 amount + ) public virtual override returns (bool) { + _transfer(sender, recipient, amount); + + uint256 currentAllowance = _allowances[sender][_msgSender()]; + require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); + + unchecked { + _approve(sender, _msgSender(), currentAllowance - amount); + } + + return true; + } + + /** + * @dev Atomically increases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + */ + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); + return true; + } + + /** + * @dev Atomically decreases the allowance granted to `spender` by the caller. + * + * This is an alternative to {approve} that can be used as a mitigation for + * problems described in {IERC20-approve}. + * + * Emits an {Approval} event indicating the updated allowance. + * + * Requirements: + * + * - `spender` cannot be the zero address. + * - `spender` must have allowance for the caller of at least + * `subtractedValue`. + */ + function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { + uint256 currentAllowance = _allowances[_msgSender()][spender]; + require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); + unchecked { + _approve(_msgSender(), spender, currentAllowance - subtractedValue); + } + + return true; + } + + /** + * @dev Moves `amount` of tokens from `sender` to `recipient`. + * + * This internal function is equivalent to {transfer}, and can be used to + * e.g. implement automatic token fees, slashing mechanisms, etc. + * + * Emits a {Transfer} event. + * + * Requirements: + * + * - `sender` cannot be the zero address. + * - `recipient` cannot be the zero address. + * - `sender` must have a balance of at least `amount`. + */ + function _transfer( + address sender, + address recipient, + uint256 amount + ) internal virtual { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + uint256 senderBalance = _balances[sender]; + require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); + unchecked { + _balances[sender] = senderBalance - amount; + } + _balances[recipient] += amount; + + emit Transfer(sender, recipient, amount); + + } + + /** + * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. + * + * This internal function is equivalent to `approve`, and can be used to + * e.g. set automatic allowances for certain subsystems, etc. + * + * Emits an {Approval} event. + * Requirements: + * + * - `owner` cannot be the zero address. + * - `spender` cannot be the zero address. + */ + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } } From 1bac07aae9c9462160f550847dd99b91b388175c Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 21:37:48 -0400 Subject: [PATCH 112/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 269 +-------------------------- 1 file changed, 1 insertion(+), 268 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 4f699ab90a4..eb2d9f67dcf 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.7; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; @@ -71,271 +72,3 @@ contract BasicToken { } } - - -pragma solidity ^0.8.7; - -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; - - - -/** title ERC20 interface - * dev see https://github.com/ethereum/EIPs/issues/20 - * openzeppelin/contracts/utils/Context.sol - * dev Implementation of the {IERC20} interface. - * - * This implementation is agnostic to the way tokens are created. This means - * that a supply mechanism has to be added in a derived contract using {_mint}. - * For a generic mechanism see {ERC20PresetMinterPauser}. - * - * TIP: For a detailed writeup see our guide - * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How - * to implement supply mechanisms]. - * - * We have followed general OpenZeppelin Contracts guidelines: functions revert - * instead returning `false` on failure. This behavior is nonetheless - * conventional and does not conflict with the expectations of ERC20 - * applications. - * - * Additionally, an {Approval} event is emitted on calls to {transferFrom}. - * This allows applications to reconstruct the allowance for all accounts just - * by listening to said events. Other implementations of the EIP may not emit - * these events, as it isn't required by the specification. - * - * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} - * functions have been added to mitigate the well-known issues around setting - * allowances. See {IERC20-approve}. - */ - -contract ERC20 is Context, IERC20, IERC20Metadata { - mapping(address => uint256) private _balances; - mapping(address => mapping(address => uint256)) private _allowances; - - string private _name; - string private _symbol; - uint8 public _decimals; - uint256 private _totalSupply; - /** - * @dev Sets the values for {name} and {symbol}. - * - * The default value of {decimals} is 18. To select a different value for - * {decimals} you should overload it. - * - * All two of these values are immutable: they can only be set once during - * construction. - */ - constructor(string memory name_, string memory symbol_) { - _name = name_; - _symbol = symbol_; - } - - /** - * @dev Returns the name of the token. - */ - function name() public view virtual override returns (string memory) { - return _name; - } - - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() public view virtual override returns (string memory) { - return _symbol; - } - - /** - * @dev Returns the number of decimals used to get its user representation. - * For example, if `decimals` equals `2`, a balance of `505` tokens should - * be displayed to a user as `5.05` (`505 / 10 ** 2`). - * - * Tokens usually opt for a value of 18, imitating the relationship between - * Ether and Wei. This is the value {ERC20} uses, unless this function is - * overridden; - * - * NOTE: This information is only used for _display_ purposes: it in - * no way affects any of the arithmetic of the contract, including - * {IERC20-balanceOf} and {IERC20-transfer}. - */ - function decimals() public view virtual override returns (uint8) { - return 18; - } - - /** - * @dev See {IERC20-totalSupply}. - */ - function totalSupply() public view virtual override returns (uint256) { - return _totalSupply; - } - - /** - * @dev See {IERC20-balanceOf}. - */ - function balanceOf(address account) public view virtual override returns (uint256) { - return _balances[account]; - } - - /** - * @dev See {IERC20-transfer}. - * - * Requirements: - * - * - `recipient` cannot be the zero address. - * - the caller must have a balance of at least `amount`. - */ - function transfer(address recipient, uint256 amount) public virtual override returns (bool) { - _transfer(_msgSender(), recipient, amount); - return true; - } - - /** - * @dev See {IERC20-allowance}. - */ - function allowance(address owner, address spender) public view virtual override returns (uint256) { - return _allowances[owner][spender]; - } - - /** - * @dev See {IERC20-approve}. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function approve(address spender, uint256 amount) public virtual override returns (bool) { - _approve(_msgSender(), spender, amount); - return true; - } - - /** - * @dev See {IERC20-transferFrom}. - * - * Emits an {Approval} event indicating the updated allowance. This is not - * required by the EIP. See the note at the beginning of {ERC20}. - * - * Requirements: - * - * - `sender` and `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - * - the caller must have allowance for ``sender``'s tokens of at least - * `amount`. - */ - function transferFrom( - address sender, - address recipient, - uint256 amount - ) public virtual override returns (bool) { - _transfer(sender, recipient, amount); - - uint256 currentAllowance = _allowances[sender][_msgSender()]; - require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); - - unchecked { - _approve(sender, _msgSender(), currentAllowance - amount); - } - - return true; - } - - /** - * @dev Atomically increases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); - return true; - } - - /** - * @dev Atomically decreases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - * - `spender` must have allowance for the caller of at least - * `subtractedValue`. - */ - function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { - uint256 currentAllowance = _allowances[_msgSender()][spender]; - require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); - unchecked { - _approve(_msgSender(), spender, currentAllowance - subtractedValue); - } - - return true; - } - - /** - * @dev Moves `amount` of tokens from `sender` to `recipient`. - * - * This internal function is equivalent to {transfer}, and can be used to - * e.g. implement automatic token fees, slashing mechanisms, etc. - * - * Emits a {Transfer} event. - * - * Requirements: - * - * - `sender` cannot be the zero address. - * - `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - */ - function _transfer( - address sender, - address recipient, - uint256 amount - ) internal virtual { - require(sender != address(0), "ERC20: transfer from the zero address"); - require(recipient != address(0), "ERC20: transfer to the zero address"); - - uint256 senderBalance = _balances[sender]; - require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); - unchecked { - _balances[sender] = senderBalance - amount; - } - _balances[recipient] += amount; - - emit Transfer(sender, recipient, amount); - - } - - - /** - * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. - * - * This internal function is equivalent to `approve`, and can be used to - * e.g. set automatic allowances for certain subsystems, etc. - * - * Emits an {Approval} event. - * - * Requirements: - * - * - `owner` cannot be the zero address. - * - `spender` cannot be the zero address. - */ - function _approve( - address owner, - address spender, - uint256 amount - ) internal virtual { - require(owner != address(0), "ERC20: approve from the zero address"); - require(spender != address(0), "ERC20: approve to the zero address"); - - _allowances[owner][spender] = amount; - emit Approval(owner, spender, amount); - } -} From 5669a5e02ab90f6c184deb733d0cd8911d430ddf Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 23:44:48 -0400 Subject: [PATCH 113/141] Update TimedCrowdsale.sol --- contracts/crowdsale/validation/TimedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index a00c3aa5f73..6e8e1fd79ed 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.7; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From 7b2dbebfc3ebe2505f376f2bf31c72073944d1b4 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 23:45:02 -0400 Subject: [PATCH 114/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 7a279042765..071297e565e 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.7; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From 65caf86bfe5f327b185f286e1828583f542b2816 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 2 Sep 2021 23:45:16 -0400 Subject: [PATCH 115/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index c613514f63e..b5ddc93c37e 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -8,7 +8,7 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; From 67fb9e7a86cc5b339fe23f03b6bd60b63e738599 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Fri, 3 Sep 2021 00:07:29 -0400 Subject: [PATCH 116/141] Update TimedCrowdsale.sol --- contracts/crowdsale/validation/TimedCrowdsale.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 6e8e1fd79ed..b73c66ecde2 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From e39320998c466ad30423391defe89860b47a36a1 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Fri, 3 Sep 2021 00:07:44 -0400 Subject: [PATCH 117/141] Update CappedCrowdsale.sol --- contracts/crowdsale/validation/CappedCrowdsale.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 071297e565e..12833974804 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; From ce5e89d97e4c935e9ff50304f5673f3fc43c3908 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Fri, 3 Sep 2021 00:07:58 -0400 Subject: [PATCH 118/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index b5ddc93c37e..1990496409f 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -8,7 +8,6 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; From 9b966fef5fbeada5d61e5ee83097b6c3f6e0c771 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 8 Sep 2021 21:59:05 -0400 Subject: [PATCH 119/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 1990496409f..4f03e310161 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -3,12 +3,10 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/BasicToken.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/MintableToken.sol"; + @@ -25,7 +23,6 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac * behavior. */ contract Crowdsale { - using SafeMath for uint256; // The token being sold ERC20 public token; From d5a51670244de1ff12a0cc059d41f8e42dc6ace1 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 10:28:35 -0400 Subject: [PATCH 120/141] Update SafeERC20.sol --- contracts/token/ERC20/SafeERC20.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 3dc721a34be..2fd063574cc 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; From d69aff9d2bc9615ed569341cad6759d74eba464b Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 10:42:45 -0400 Subject: [PATCH 121/141] Update SafeERC20.sol --- contracts/token/ERC20/SafeERC20.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 2fd063574cc..823a6b9c1b4 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,10 +1,7 @@ // SPDX-License-Identifier: MIT - pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; - /** * @title SafeERC20 From 96028753bce8b409b875f217f2e3545509b35436 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 10:45:04 -0400 Subject: [PATCH 122/141] Update SafeERC20.sol --- contracts/token/ERC20/SafeERC20.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 823a6b9c1b4..ccf68ab0d68 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; - /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure. From a075ce65bc51fc7e3eba25b09a2045f287cc2d94 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 17:48:45 -0400 Subject: [PATCH 123/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 4f03e310161..48d18eda797 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; From b844e69c9b2158c064aff34ff0b354e061e3c5ea Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 17:49:35 -0400 Subject: [PATCH 124/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 48d18eda797..554df4166c6 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; From 0a30becf59dc738b7199f67d1f5ee5ad21a92868 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 17:52:14 -0400 Subject: [PATCH 125/141] Update ERC20.sol --- contracts/token/ERC20/ERC20.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index b3d7823065a..79f1200684f 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -3,8 +3,6 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; /** title ERC20 interface From 5dde528171c339cbd902c16480ccfc497fd0c498 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 17:54:43 -0400 Subject: [PATCH 126/141] Update StandardToken.sol --- contracts/token/ERC20/StandardToken.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/contracts/token/ERC20/StandardToken.sol b/contracts/token/ERC20/StandardToken.sol index dd4a3903e89..b71c991e864 100644 --- a/contracts/token/ERC20/StandardToken.sol +++ b/contracts/token/ERC20/StandardToken.sol @@ -2,11 +2,7 @@ pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; - contract BasicToken { /* *This creates an array with all balancesOf */ From ab53b6e225c86f99d23b403e25c9721d2d1ab7cd Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 17:56:56 -0400 Subject: [PATCH 127/141] Update MintableToken.sol --- contracts/token/ERC20/MintableToken.sol | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/MintableToken.sol b/contracts/token/ERC20/MintableToken.sol index c077711535e..8eb630923c0 100644 --- a/contracts/token/ERC20/MintableToken.sol +++ b/contracts/token/ERC20/MintableToken.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/StandardToken.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/ownership/Ownable.sol"; @@ -12,7 +11,7 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ -contract MintableToken is StandardToken, Ownable { +contract MintableToken is Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); From e45f824f04d6fd8b79b1b92acaf1b41942f05dc8 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 19:31:22 -0400 Subject: [PATCH 128/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index eb2d9f67dcf..0983c89f122 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -3,9 +3,6 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20Metadata.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; From 5305756df571aeeef174f38513978284ea05572c Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 19:32:20 -0400 Subject: [PATCH 129/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 0983c89f122..11c0618ea4f 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20Basic.sol"; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; From b9b3d553c1383fd9f58f9db2d7983d19d7d5f1ec Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 20:00:21 -0400 Subject: [PATCH 130/141] Update Context.sol --- contracts/token/ERC20/Context.sol | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contracts/token/ERC20/Context.sol b/contracts/token/ERC20/Context.sol index 51853cdcb0a..fb0c0fa2a66 100644 --- a/contracts/token/ERC20/Context.sol +++ b/contracts/token/ERC20/Context.sol @@ -1,8 +1,10 @@ +// File: @openzeppelin/contracts/utils/Context.sol + // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.7; -/** +/* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct @@ -18,6 +20,7 @@ abstract contract Context { } function _msgData() internal view virtual returns (bytes calldata) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } From 1ab8acf33557bea79a7eca0e0f4bf6acbeab25f4 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 20:03:38 -0400 Subject: [PATCH 131/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 554df4166c6..41de22bfd55 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -3,10 +3,7 @@ pragma solidity ^0.8.7; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/Context.sol"; - - - +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; /** * @title Crowdsale From 5cc18fac8a0430bd3c696f55b633f03628514e75 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Thu, 9 Sep 2021 20:18:05 -0400 Subject: [PATCH 132/141] Update BasicToken.sol --- contracts/token/ERC20/BasicToken.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/token/ERC20/BasicToken.sol b/contracts/token/ERC20/BasicToken.sol index 11c0618ea4f..d3142b1e106 100644 --- a/contracts/token/ERC20/BasicToken.sol +++ b/contracts/token/ERC20/BasicToken.sol @@ -2,8 +2,6 @@ pragma solidity ^0.8.7; -import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; - contract BasicToken { /* *This creates an array with all balancesOf */ From ed9773d180f42f4a0b4fc9983c1a4074d1403ae8 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Sat, 11 Sep 2021 21:53:40 -0400 Subject: [PATCH 133/141] Update CappedCrowdsale.sol --- .../crowdsale/validation/CappedCrowdsale.sol | 66 ++++++++----------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 12833974804..385c4a80693 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -2,48 +2,38 @@ pragma solidity ^0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/crowdsale/Crowdsale.sol"; - +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; /** * @title CappedCrowdsale * @dev Crowdsale with a limit for total contributions. */ -contract CappedCrowdsale is Crowdsale { - using SafeMath for uint256; - - uint256 public cap; - - /** - * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. - * @param _cap Max amount of wei to be contributed - */ - constructor(uint256 _cap) public { - require(_cap > 0); - cap = _cap; - } - - /** - * @dev Checks whether the cap has been reached. - * @return Whether the cap was reached - */ - function capReached() public view returns (bool) { - return weiRaised >= cap; - } - - /** - * @dev Extend parent behavior requiring purchase to respect the funding cap. - * @param _beneficiary Token purchaser - * @param _weiAmount Amount of wei contributed - */ - function _preValidatePurchase( - address _beneficiary, - uint256 _weiAmount - ) - internal - { - super._preValidatePurchase(_beneficiary, _weiAmount); - require(weiRaised.add(_weiAmount) <= cap); - } +abstract contract ERC20Capped is ERC20 { + uint256 public _cap=300000000000000000000; // 300 ETH = 300*10^18 wei = 300000000000000000000 wei; + + /** + * @dev Sets the value of the `cap`. This value is immutable, it can only be + * set once during construction. + */ + constructor(uint256 cap_) { + require(cap_ > 0, "ERC20Capped: cap is 300000000000000000000"); + _cap = cap_; + } + + /** + * @dev Returns the cap on the token's total supply. + */ + function cap() public view virtual returns (uint256) { + return _cap; + } + + /** + * @dev See {ERC20-_mint}. + */ + function _mint(address account, uint256 amount) internal virtual override { + require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); + super._mint(account, amount); + } + } From 629c50446312e9868bdb83c3a9fcb334507b6f34 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Sat, 11 Sep 2021 22:31:40 -0400 Subject: [PATCH 134/141] Update CappedCrowdsale.sol --- .../crowdsale/validation/CappedCrowdsale.sol | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 385c4a80693..3ac2d1606ad 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -10,14 +10,28 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac */ abstract contract ERC20Capped is ERC20 { + uint256 public _cap=300000000000000000000; // 300 ETH = 300*10^18 wei = 300000000000000000000 wei; + //minimum investor Contribution - 1 + //maximum investor Contribution - 300 wei is similar maxium daily 300 ETH crowdsale + uint256 public investorMinCap = 1000000000000000000; // 1 ETH = 10^18 wei = 1000000000000000000 wei + uint256 public investorHardCap = 300000000000000000000; // 300 ETH = 300*10^18 wei = 300000000000000000000 wei + + // start and end timestamps where investments are allowed (both inclusive) + uint256 public startTime; + uint256 public endTime; + + mapping(address => uint256) public contributions; + /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ - constructor(uint256 cap_) { + constructor(uint256 cap_, uint256 _openingTime, uint256 _closingTime) { require(cap_ > 0, "ERC20Capped: cap is 300000000000000000000"); + require(_openingTime >= block.timestamp); + require(_closingTime >= _openingTime); _cap = cap_; } @@ -35,5 +49,8 @@ abstract contract ERC20Capped is ERC20 { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } - + + + } + From e339504b4f31a03cbad1e09963ca2548f265611e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Mon, 13 Sep 2021 19:57:53 -0400 Subject: [PATCH 135/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 111 ++++++++++++++++++------------ 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 41de22bfd55..9cba49141e2 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,9 +1,10 @@ -// SPDX-License-Identifier: MIT License Modern Variant +// SPDX-License-Identifier: MIT License -pragma solidity ^0.8.7; +pragma solidity 0.8.7; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/ERC20.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; + /** * @title Crowdsale @@ -18,19 +19,31 @@ import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contrac * behavior. */ contract Crowdsale { + using SafeMath for uint256; - // The token being sold - ERC20 public token; + // How many token units a buyer gets per wei. + // The rate is the conversion between wei and the smallest and indivisible token unit. + // So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK + // 1 wei will give you 1 unit, or 0.001 TOK. + uint256 public rate; - // Address where funds are collected - address public wallet; + // Address where funds are collected + address payable wallet; - // How many token units a buyer gets per wei - uint256 public rate; + // The token being sold + address public token; // Amount of wei raised uint256 public weiRaised; + // Public Supply + uint256 public publicSupply; + + // start and end timestamps where investments are allowed (both inclusive) + uint256 public startTime; + uint256 public endTime; + + /** * Event for token purchase logging * @param purchaser who paid for the tokens @@ -46,32 +59,51 @@ contract Crowdsale { ); /** - * @param _rate Number of token units a buyer gets per wei - * @param _wallet Address where collected funds will be forwarded to - * @param _token Address of the token being sold + * param _rate Number of token units a buyer gets per wei + * param _wallet Address where collected funds will be forwarded to + * param _token Address of the token being sold */ - constructor(uint256 _rate, address _wallet, ERC20 _token) public { + +constructor (uint256 _startTime, uint256 _endTime, uint256 _rate, address payable _wallet, address _token) { + require(_startTime >= block.timestamp); + require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); - require(_token != address(0)); - + require(address(token) != address(0)); + startTime = _startTime; + endTime = _endTime; rate = _rate; wallet = _wallet; token = _token; + } + + // ----------------------------------------- // Crowdsale external interface // ----------------------------------------- + /** + * @dev fallback function ***DO NOT OVERRIDE*** + */ + fallback () external payable { + buyTokens(msg.sender); + } + + receive () external payable { + buyTokens(msg.sender); + } + + /** * @dev low level token purchase ***DO NOT OVERRIDE*** * @param _beneficiary Address performing the token purchase */ - function buyTokens(address _beneficiary) public payable { - + function buyTokens(address _beneficiary) public payable { + require(_beneficiary != address(0)); uint256 weiAmount = msg.value; - _preValidatePurchase(_beneficiary, weiAmount); + // _preValidatePurchase(_beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); @@ -79,18 +111,14 @@ contract Crowdsale { // update state weiRaised = weiRaised.add(weiAmount); - _processPurchase(_beneficiary, tokens); - emit TokenPurchase( - msg.sender, - _beneficiary, - weiAmount, - tokens - ); + // _processPurchase(_beneficiary, token); + emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); - _postValidatePurchase(_beneficiary, weiAmount); + + } // ----------------------------------------- @@ -101,7 +129,7 @@ contract Crowdsale { * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations. * @param _beneficiary Address performing the token purchase * @param _weiAmount Value in wei involved in the purchase - */ + function _preValidatePurchase( address _beneficiary, uint256 _weiAmount @@ -111,40 +139,32 @@ contract Crowdsale { require(_beneficiary != address(0)); require(_weiAmount != 0); } - - /** - * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met. - * @param _beneficiary Address performing the token purchase - * @param _weiAmount Value in wei involved in the purchase - */ - function _postValidatePurchase( - address _beneficiary, - uint256 _weiAmount - ) - internal - { - // optional override - } + +*/ /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens. * @param _beneficiary Address performing the token purchase * @param _tokenAmount Number of tokens to be emitted - */ + + function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { - token.transfer(_beneficiary, _tokenAmount); + token.transfer(_beneficiary, _tokenAmount); } + */ + + /** * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _beneficiary Address receiving the tokens * @param _tokenAmount Number of tokens to be purchased - */ + function _processPurchase( address _beneficiary, uint256 _tokenAmount @@ -154,6 +174,9 @@ contract Crowdsale { _deliverTokens(_beneficiary, _tokenAmount); } + */ + + /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.) * @param _beneficiary Address receiving the tokens From cee41e9a4bfc549aa88606b293afabc9a5fa63b3 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 25 Jan 2022 19:21:43 -0500 Subject: [PATCH 136/141] Update IERC20Metadata.sol --- contracts/token/ERC20/IERC20Metadata.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/IERC20Metadata.sol b/contracts/token/ERC20/IERC20Metadata.sol index b1c51954950..2535622ac8a 100644 --- a/contracts/token/ERC20/IERC20Metadata.sol +++ b/contracts/token/ERC20/IERC20Metadata.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.4; +pragma solidity ^0.8.0; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; From 66f8fdd0f7429b3ebe66d474a6d00955b6ad503b Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 25 Jan 2022 19:32:51 -0500 Subject: [PATCH 137/141] Update IERC20Metadata.sol --- contracts/token/ERC20/IERC20Metadata.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/token/ERC20/IERC20Metadata.sol b/contracts/token/ERC20/IERC20Metadata.sol index 2535622ac8a..bca2e2f3901 100644 --- a/contracts/token/ERC20/IERC20Metadata.sol +++ b/contracts/token/ERC20/IERC20Metadata.sol @@ -2,7 +2,8 @@ pragma solidity ^0.8.0; -import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol"; +import "https://github.com/vclcash123/openzeppelin-solidity/blob/master/contracts/token/ERC20/IERC20.sol"; + /** * @dev Interface for the optional metadata functions from the ERC20 standard. From bcedf6badba92f1bc7a01d6ba2b26aae5b26b97e Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 12 Sep 2023 23:33:36 -0400 Subject: [PATCH 138/141] Update SafeMath.sol --- contracts/token/ERC20/SafeMath.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/SafeMath.sol b/contracts/token/ERC20/SafeMath.sol index 806ce8f97ea..c5e49c1bb5d 100644 --- a/contracts/token/ERC20/SafeMath.sol +++ b/contracts/token/ERC20/SafeMath.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.7; +pragma solidity ^0.7.2; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, From 67e0f7f5a0b7bd261ded65af0ee89e0e2250d4e0 Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Tue, 12 Sep 2023 23:34:02 -0400 Subject: [PATCH 139/141] Update IERC20.sol --- contracts/token/ERC20/IERC20.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/IERC20.sol b/contracts/token/ERC20/IERC20.sol index 1ed2a0c36d8..10dbf358386 100644 --- a/contracts/token/ERC20/IERC20.sol +++ b/contracts/token/ERC20/IERC20.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.8.7; +pragma solidity ^0.7.2; /** * @dev Interface of the ERC20 standard as defined in the EIP. From ca1db6208b6ab8653c155e739314725d60fde23b Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:15:08 -0400 Subject: [PATCH 140/141] Update SafeMath.sol --- contracts/token/ERC20/SafeMath.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC20/SafeMath.sol b/contracts/token/ERC20/SafeMath.sol index c5e49c1bb5d..9a76141f105 100644 --- a/contracts/token/ERC20/SafeMath.sol +++ b/contracts/token/ERC20/SafeMath.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT License Modern Variant -pragma solidity ^0.7.2; +pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, From 601b618a39cfcc509e720fd9ad35175469181b0c Mon Sep 17 00:00:00 2001 From: VinhPhuLuc <86334635+vclcash123@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:02:16 -0400 Subject: [PATCH 141/141] Update Crowdsale.sol --- contracts/crowdsale/Crowdsale.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 9cba49141e2..aad831477a9 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT License -pragma solidity 0.8.7; +pragma solidity ^0.8.9; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/SafeMath.sol"; import "https://github.com/vclcash123/openzeppelin-solidity/blob/patch-2/contracts/token/ERC20/IERC20.sol";