Skip to content

Commit ef5e422

Browse files
authored
Sayfer audit fix (#292)
* add: xdc upgrade script fixes * add: sayer audit fixes * add: etherscan update * fix: identity fix failng test * fix: yarn.lock
1 parent c60d304 commit ef5e422

7 files changed

Lines changed: 351 additions & 74 deletions

File tree

contracts/identity/IdentityV3.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ contract IdentityV3 is
3535
string public constant TYPED_STRUCTURE =
3636
"ConnectIdentity(address whitelisted,address connected,uint256 deadline)";
3737

38+
/* @dev rough estimate of number of whitelisted addresses */
3839
uint256 public whitelistedCount;
3940
uint256 public whitelistedContracts;
4041
uint256 public authenticationPeriod;
@@ -236,6 +237,7 @@ contract IdentityV3 is
236237
function addBlacklisted(
237238
address account
238239
) public onlyRole(IDENTITY_ADMIN_ROLE) whenNotPaused {
240+
_removeWhitelisted(account);
239241
identities[account].status = 255;
240242
emit BlacklistAdded(account);
241243
}

contracts/reserve/GenericDistributionHelper.sol

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ contract GenericDistributionHelper is
5858

5959
address public reserveToken;
6060

61+
uint256 private _status; //for reentrancy guard
62+
6163
event Distribution(
6264
uint256 distributed,
6365
uint256 startingBalance,
@@ -76,6 +78,18 @@ contract GenericDistributionHelper is
7678

7779
receive() external payable {}
7880

81+
modifier nonReentrant() {
82+
// On the first call to nonReentrant, _status will be _NOT_ENTERED
83+
require(_status != 1, "ReentrancyGuard: reentrant call");
84+
85+
// Any calls to nonReentrant after this point will fail
86+
_status = 1;
87+
_;
88+
// By storing the original value once again, a refund is triggered (see
89+
// https://eips.ethereum.org/EIPS/eip-2200)
90+
_status = 0;
91+
}
92+
7993
function initialize(
8094
INameService _ns,
8195
IStaticOracle _oracle,
@@ -129,7 +143,7 @@ contract GenericDistributionHelper is
129143
* @notice this is usually called by reserve, but can be called by anyone anytime to trigger distribution
130144
* @param _amount how much was sent, informational only
131145
*/
132-
function onDistribution(uint256 _amount) external virtual {
146+
function onDistribution(uint256 _amount) external virtual nonReentrant {
133147
//we consider the actual balance and not _amount
134148
uint256 toDistribute = nativeToken().balanceOf(address(this));
135149
if (toDistribute == 0) return;
@@ -300,7 +314,7 @@ contract GenericDistributionHelper is
300314
}
301315
for (uint i = 1; i < gdPools.length; i++) {
302316
uint24 fee = IUniswapV3Pool(gdPools[i]).fee();
303-
gdFee = gasFee < fee ? gasFee : fee;
317+
gdFee = gdFee < fee ? gdFee : fee;
304318
}
305319
ERC20(nativeToken()).approve(address(ROUTER), amountToSell);
306320
uint256 amountOutMinimum = (minReceived * (100 - feeSettings.maxSlippage)) /

hardhat.config.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const MAINNET_URL = "https://mainnet.infura.io/v3/" + infura_api;
4141

4242
const xdc = {
4343
accounts: { mnemonic },
44-
url: "https://rpc.ankr.com/xdc/ef07ba6590dc46db9275bba237aed203ed6d5fb3e3203ff237a82a841f75b2ce",
44+
url: "https://rpc.ankr.com/xdc",
4545
gas: 3000000,
4646
gasPrice: 12.5e9,
4747
chainId: 50
@@ -65,15 +65,7 @@ const hhconfig: HardhatUserConfig = {
6565
enabled: true
6666
},
6767
etherscan: {
68-
apiKey: {
69-
mainnet: etherscan_key,
70-
txdc: etherscan_key,
71-
xdc: etherscan_key,
72-
celo: etherscan_key,
73-
alfajores: celoscan_key,
74-
base: basescan_key,
75-
fuse: etherscan_key
76-
},
68+
apiKey: etherscan_key,
7769
customChains: [
7870
{
7971
network: "fuse",

releases/deployment.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,8 @@
684684
"AdminWallet": "0x66fc1bE551f752706130b6f54d84141F8c2Ae8Bb",
685685
"Faucet": "0x7344Da1Be296f03fbb8082aDaC5696058B5a9bd9",
686686
"Invites": "0x6bd698566632bf2e81e2278f1656CB24aAF06D2e",
687-
"UBIScheme": "0x22867567E2D80f2049200E25C6F31CB6Ec2F0faf"
687+
"UBIScheme": "0x22867567E2D80f2049200E25C6F31CB6Ec2F0faf",
688+
"MpbBridge": "0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5",
689+
"BulkWhitelist": "0xe8861A20452Db53dF685F1d9e6B7017de3DB0E46"
688690
}
689691
}

scripts/multichain-deploy/helpers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TransactionResponse, TransactionReceipt } from "@ethersproject/provider
55
import { getImplementationAddress } from "@openzeppelin/upgrades-core";
66

77
import SafeApiKit from "@safe-global/api-kit";
8-
import Safe from "@safe-global/protocol-kit";
8+
import Safe, { SafeTransactionOptionalProps } from "@safe-global/protocol-kit";
99
import { MetaTransactionData } from "@safe-global/types-kit";
1010

1111
import util from "util";
@@ -357,6 +357,7 @@ export const executeViaSafe = async (
357357
functionInputs,
358358
safeAddress: string,
359359
safeSignerOrNetwork?: Signer | string,
360+
safeOptions: SafeTransactionOptionalProps = {},
360361
isSimulation = false
361362
) => {
362363
if (typeof safeSignerOrNetwork !== "object" && !process.env.SAFEOWNER_PRIVATE_KEY) {
@@ -387,6 +388,10 @@ export const executeViaSafe = async (
387388
// new ethers.providers.JsonRpcProvider("https://rpc.fuse.io")
388389
// );
389390
break;
391+
case "xdc":
392+
chainId = 50;
393+
provider = "https://rpc.xdcrpc.com";
394+
break;
390395
}
391396
} else if (safeSignerOrNetwork) {
392397
// safeSigner = safeSignerOrNetwork as any;

0 commit comments

Comments
 (0)