Skip to content

Commit

Permalink
ensure oracle cannot be initialized with zero address
Browse files Browse the repository at this point in the history
  • Loading branch information
JCSanPedro committed Feb 20, 2024
1 parent 6b2ccca commit ea6f0cf
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
5 changes: 5 additions & 0 deletions contracts/SeekerPowerOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ contract SeekerPowerOracle is ISeekerPowerOracle, Initializable, Ownable2StepUpg
error UnauthorizedRegisterSeekerPowerCall();
error NonceCannotBeReused();
error PowerCannotBeZero();
error OracleCannotBeZeroAddress();

function initialize(address _oracle) external initializer {
Ownable2StepUpgradeable.__Ownable2Step_init();

if (_oracle == address(0)) {
revert OracleCannotBeZeroAddress();
}

oracle = _oracle;
}

Expand Down
28 changes: 14 additions & 14 deletions deployments/ganache_deployment_phase_two.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"deployer": "0x835dF5fE77D479695a616F79A3FC3a25310eb7c6",
"syloToken": "0xc4db8fD3209c98290AB32693F5155c596B97Eabe",
"authorizedAccounts": "0x075EEeD1215982b78A2e05cD2213b5f53A718a9A",
"registries": "0xFB87c433852Bb2917B37b0471DFA5B369e75083A",
"ticketingParameters": "0x65A9be6e97eD2F417250A819e93BCb359b1140d0",
"epochsManager": "0x7bFCE7796fdE3Ba0F2052959d506bdA480518edA",
"stakingManager": "0xa4dE4FEA5e961e5C130013CfE207f7C08148A73C",
"rewardsManager": "0x4aa109E0DB0223ed2d9085679F450EfDf188CFf6",
"directory": "0x7E7C762176eaa1662d372399265760d4600CCf28",
"syloTicketing": "0x943E7031A7Ed0FC236173f05a3084104b81Aa480",
"seekers": "0x49C537a88016186Ef41713239799Fc975F9e9aFA",
"seekerPowerOracle": "0xca7efb9aA54e70F7a8e7efb878A48BaefA34F4AC",
"futurepassRegistrar": "0x7DBf77bb534997892e5Bcfbdc79Dd82E71C35245"
}
"deployer": "0x835dF5fE77D479695a616F79A3FC3a25310eb7c6",
"syloToken": "0xc4db8fD3209c98290AB32693F5155c596B97Eabe",
"authorizedAccounts": "0x075EEeD1215982b78A2e05cD2213b5f53A718a9A",
"registries": "0xFB87c433852Bb2917B37b0471DFA5B369e75083A",
"ticketingParameters": "0x65A9be6e97eD2F417250A819e93BCb359b1140d0",
"epochsManager": "0x7bFCE7796fdE3Ba0F2052959d506bdA480518edA",
"stakingManager": "0xa4dE4FEA5e961e5C130013CfE207f7C08148A73C",
"rewardsManager": "0x4aa109E0DB0223ed2d9085679F450EfDf188CFf6",
"directory": "0x7E7C762176eaa1662d372399265760d4600CCf28",
"syloTicketing": "0x943E7031A7Ed0FC236173f05a3084104b81Aa480",
"seekers": "0x49C537a88016186Ef41713239799Fc975F9e9aFA",
"seekerPowerOracle": "0xca7efb9aA54e70F7a8e7efb878A48BaefA34F4AC",
"futurepassRegistrar": "0x7DBf77bb534997892e5Bcfbdc79Dd82E71C35245"
}
4 changes: 2 additions & 2 deletions deployments/genesis.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const GenesisParameters: ContractParameters = {
},

SeekerPowerOracle: {
oracleAccount: '0x835dF5fE77D479695a616F79A3FC3a25310eb7c6',
oracleAccount: '',
},
};

Expand Down Expand Up @@ -127,7 +127,7 @@ const GanacheTestnetParameters: ContractParameters = {
},

SeekerPowerOracle: {
oracleAccount: '',
oracleAccount: '0x835dF5fE77D479695a616F79A3FC3a25310eb7c6', // deployer
},
};

Expand Down
14 changes: 14 additions & 0 deletions test/seekerOracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ describe('Seeker Power Oracle', () => {
contracts = await utils.initializeContracts(deployer, token);
});

it('seeker power oracle cannot be initialized with invalid arguments', async () => {
const SeekerPowerOracle = await ethers.getContractFactory(
'SeekerPowerOracle',
);
const seekerPowerOracle = await SeekerPowerOracle.deploy();

await expect(
seekerPowerOracle.initialize(ethers.ZeroAddress),
).to.be.revertedWithCustomError(
seekerPowerOracle,
'OracleCannotBeZeroAddress',
);
});

it('seeker power oracle cannot be initialized twice', async () => {
await expect(
contracts.seekerPowerOracle.initialize(deployer),
Expand Down
2 changes: 1 addition & 1 deletion test/staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ describe('Staking', () => {
it('cannot join directory with invalid arguments', async () => {
await directory.addManager(owner);
await expect(
directory.joinNextDirectory(ethers.ZeroAddress, 1),
directory.joinNextDirectory(ethers.ZeroAddress, defaultSeekerId),
).to.be.revertedWithCustomError(directory, 'StakeeCannotBeZeroAddress');
});

Expand Down

0 comments on commit ea6f0cf

Please sign in to comment.