Skip to content

Commit

Permalink
Code423n4 #115, #142, missing zero validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Splidge committed Jun 21, 2021
1 parent 1f395f8 commit cb84f08
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 12 deletions.
4 changes: 4 additions & 0 deletions contracts/nfthubs/RCNftHubL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ contract RCNftHubL2 is
constructor(address _factoryAddress, address childChainManager)
ERC721("RealityCards", "RC")
{
require(
childChainManager != address(0),
"Must add childChainManager address"
);
// initialise MetaTransactions
_initializeEIP712("RealityCardsNftHubL2", "1");
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestFactory', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsFullFlowInvalid.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestFullFlowInvalid', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsFullFlowValid.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = "0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D";
Expand Down Expand Up @@ -96,7 +98,7 @@ contract("TestFullFlowValid", (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsFundamentals.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestFundamentals', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsGasLimits.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
var kleros = "0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D";
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';
// an array of market instances
var market = [];
// an array of the addresses (just a more readable way of doing market[].address)
Expand Down Expand Up @@ -70,7 +72,7 @@ contract("TestTreasury", (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsNftHubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestNftHubs', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsOrderbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestOrderbook', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsOwnership.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestOwnership', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsProxies.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestProxies', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
4 changes: 3 additions & 1 deletion test/OldTests/testsRequireStatements.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var RealitioMockup = artifacts.require("./mockups/RealitioMockup.sol");
var SelfDestructMockup = artifacts.require("./mockups/SelfDestructMockup.sol");
var DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';

// arbitrator
var kleros = '0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D';
Expand Down Expand Up @@ -73,7 +75,7 @@ contract('TestRequireStatements', (accounts) => {
rcreference = await RCMarket.new();
rcorderbook = await RCOrderbook.new(rcfactory.address, treasury.address);
// nft hubs
nftHubL2 = await NftHubL2.new(rcfactory.address, ZERO_ADDRESS);
nftHubL2 = await NftHubL2.new(rcfactory.address, dummyAddress);
nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await treasury.setFactoryAddress(rcfactory.address);
Expand Down
6 changes: 4 additions & 2 deletions test/helpers/TestEnviroment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const DaiMockup = artifacts.require("./mockups/DaiMockup.sol");
const kleros = "0xd47f72a2d1d0E91b0Ec5e5f5d02B2dc26d00A14D";
const zeroAddress = "0x0000000000000000000000000000000000000000";
const tokenMockup = artifacts.require("./mockups/tokenMockup.sol");
// used where the address isn't important but can't be zero
const dummyAddress = '0x0000000000000000000000000000000000000001';



Expand Down Expand Up @@ -75,8 +77,8 @@ module.exports = class TestEnviroment {
this.contracts.factory = await RCFactory.new(this.contracts.treasury.address, this.contracts.realitio.address, kleros);
this.contracts.reference = await RCMarket.new();
this.contracts.orderbook = await RCOrderbook.new(this.contracts.factory.address, this.contracts.treasury.address);
// nft hubs
this.contracts.nftHubL2 = await NftHubL2.new(this.contracts.factory.address, this.constants.ZERO_ADDRESS);
// nft hubs
this.contracts.nftHubL2 = await NftHubL2.new(this.contracts.factory.address, dummyAddress);
this.contracts.nftHubL1 = await NftHubL1.new();
// tell treasury about factory, tell factory about nft hub and reference
await this.contracts.treasury.setFactoryAddress(this.contracts.factory.address);
Expand Down

0 comments on commit cb84f08

Please sign in to comment.