Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions contracts/core/Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ contract Core is
*
* @param _transferProxy The address of the transfer proxy
* @param _vault The address of the vault
* @param _signatureValidator The address of the signature validator
*/
constructor(
address _transferProxy,
address _vault,
address _signatureValidator
address _vault
)
public
{
Expand All @@ -67,8 +65,5 @@ contract Core is

// Instantiate instance of vault
state.vaultInstance = IVault(_vault);

// Commit passed address to signatureValidator state variable
state.signatureValidator = _signatureValidator;
}
}
23 changes: 0 additions & 23 deletions contracts/core/extensions/CoreInternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ contract CoreInternal is
address _priceLibrary
);

event SignatureValidatorChanged(
address _signatureValidator
);

/* ============ External Functions ============ */

/**
Expand Down Expand Up @@ -294,23 +290,4 @@ contract CoreInternal is
_priceLibrary
);
}

/**
* Change address of the Signature Validator contract
*
* @param _signatureValidator Address of the Signature Validator library
*/
function setSignatureValidator(
address _signatureValidator
)
external
onlyOwner
timeLockUpgrade
{
state.signatureValidator = _signatureValidator;

emit SignatureValidatorChanged(
_signatureValidator
);
}
}
10 changes: 0 additions & 10 deletions contracts/core/interfaces/ICore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ interface ICore {
view
returns(bool);

/**
* Return signatureValidator address
*
* @return address signatureValidator address
*/
function signatureValidator()
external
view
returns(address);

/**
* Exchanges components for Set Tokens
*
Expand Down
16 changes: 0 additions & 16 deletions contracts/core/lib/CoreState.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ contract CoreState {
// Mapping of approved modules
mapping(address => bool) validModules;

// Address of the Signature Validator contract
address signatureValidator;

// Mapping of tracked SetToken factories
mapping(address => bool) validFactories;

Expand Down Expand Up @@ -133,19 +130,6 @@ contract CoreState {
return state.vault;
}

/**
* Return signatureValidator address
*
* @return address signatureValidator address
*/
function signatureValidator()
external
view
returns(address)
{
return state.signatureValidator;
}

/**
* Return boolean indicating if address is valid factory.
*
Expand Down
43 changes: 40 additions & 3 deletions contracts/core/modules/IssuanceOrderModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pragma solidity 0.4.25;
pragma experimental "ABIEncoderV2";

import { Math } from "openzeppelin-solidity/contracts/math/Math.sol";
import { Ownable } from "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import { ReentrancyGuard } from "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol";
import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";

Expand All @@ -33,6 +34,7 @@ import { IVault } from "../interfaces/IVault.sol";
import { LibBytes } from "../../external/0x/LibBytes.sol";
import { ModuleCoreState } from "./lib/ModuleCoreState.sol";
import { OrderLibrary } from "../lib/OrderLibrary.sol";
import { TimeLockUpgrade } from "../../lib/TimeLockUpgrade.sol";


/**
Expand All @@ -44,6 +46,8 @@ import { OrderLibrary } from "../lib/OrderLibrary.sol";
*/
contract IssuanceOrderModule is
ModuleCoreState,
Ownable,
TimeLockUpgrade,
ReentrancyGuard
{
using SafeMath for uint256;
Expand All @@ -57,6 +61,10 @@ contract IssuanceOrderModule is
// Mapping of canceled Issuance Orders
mapping(bytes32 => uint256) public orderCancels;

// Address of signature validator
address public signatureValidator;
ISignatureValidator public signatureValidatorInstance;

/* ============ Events ============ */

event LogFill(
Expand All @@ -81,6 +89,10 @@ contract IssuanceOrderModule is
bytes32 orderHash
);

event SignatureValidatorChanged(
address _signatureValidator
);

/* ============ Constructor ============ */

/**
Expand All @@ -89,19 +101,44 @@ contract IssuanceOrderModule is
* @param _core The address of Core
* @param _transferProxy The address of transferProxy
* @param _vault The address of Vault
* @param _signatureValidator The address of SignatureValidator
*/
constructor(
address _core,
address _transferProxy,
address _vault
address _vault,
address _signatureValidator
)
public
ModuleCoreState(
_core,
_transferProxy,
_vault
)
{}
{
// Commit the signature validator address and instance
signatureValidator = _signatureValidator;
signatureValidatorInstance = ISignatureValidator(signatureValidator);
}

/**
* Change address of the Signature Validator contract
*
* @param _signatureValidator Address of the Signature Validator library
*/
function setSignatureValidator(
address _signatureValidator
)
external
onlyOwner
timeLockUpgrade
{
signatureValidator = _signatureValidator;

emit SignatureValidatorChanged(
_signatureValidator
);
}

/* ============ External Functions ============ */

Expand Down Expand Up @@ -258,7 +295,7 @@ contract IssuanceOrderModule is

// Verify signature is authentic, if already been filled before skip to save gas
if (orderFills[_orderHash] == 0) {
ISignatureValidator(coreInstance.signatureValidator()).validateSignature(
signatureValidatorInstance.validateSignature(
_orderHash,
_order.makerAddress,
_signature
Expand Down
5 changes: 2 additions & 3 deletions contracts/mocks/core/CoreMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { ISetToken } from "../../core/interfaces/ISetToken.sol";
contract CoreMock is Core {
constructor(
address _transferProxy,
address _vault,
address _signatureValidator
address _vault
)
public
Core(_transferProxy, _vault, _signatureValidator)
Core(_transferProxy, _vault)
{}

/*
Expand Down
13 changes: 1 addition & 12 deletions test/contracts/core/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Address } from 'set-protocol-utils';

import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import { CoreContract, SignatureValidatorContract, TransferProxyContract, VaultContract } from '@utils/contracts';
import { CoreContract, TransferProxyContract, VaultContract } from '@utils/contracts';
import { Blockchain } from '@utils/blockchain';
import { getWeb3 } from '@utils/web3Helper';

Expand All @@ -27,7 +27,6 @@ contract('Core', accounts => {

let transferProxy: TransferProxyContract;
let vault: VaultContract;
let signatureValidator: SignatureValidatorContract;

const coreWrapper = new CoreWrapper(ownerAccount, ownerAccount);

Expand All @@ -53,14 +52,12 @@ contract('Core', accounts => {
beforeEach(async () => {
transferProxy = await coreWrapper.deployTransferProxyAsync();
vault = await coreWrapper.deployVaultAsync();
signatureValidator = await coreWrapper.deploySignatureValidatorAsync();
});

async function subject(): Promise<CoreContract> {
return await coreWrapper.deployCoreAsync(
transferProxy,
vault,
signatureValidator,
subjectCaller,
);
}
Expand All @@ -80,13 +77,5 @@ contract('Core', accounts => {

expect(vaultAddress).to.equal(vault.address);
});

it('should contain the correct address of the signatureValidator', async () => {
const coreContract = await subject();

const signatureValidatorAddress = await coreContract.signatureValidator.callAsync();

expect(signatureValidatorAddress).to.equal(signatureValidator.address);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
KyberNetworkWrapperContract,
SignatureValidatorContract,
StandardTokenMockContract,
TransferProxyContract,
VaultContract,
Expand Down Expand Up @@ -51,7 +50,6 @@ contract('KyberNetworkWrapper', accounts => {
let core: CoreContract;
let transferProxy: TransferProxyContract;
let vault: VaultContract;
let signatureValidator: SignatureValidatorContract;

let kyberNetworkWrapper: KyberNetworkWrapperContract;

Expand All @@ -60,8 +58,7 @@ contract('KyberNetworkWrapper', accounts => {

transferProxy = await coreWrapper.deployTransferProxyAsync();
vault = await coreWrapper.deployVaultAsync();
signatureValidator = await coreWrapper.deploySignatureValidatorAsync();
core = await coreWrapper.deployCoreMockAsync(transferProxy, vault, signatureValidator);
core = await coreWrapper.deployCoreMockAsync(transferProxy, vault);
await coreWrapper.addModuleAsync(core, issuanceOrderModuleAccount);

kyberNetworkWrapper = await exchangeWrapper.deployKyberNetworkWrapper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
SignatureValidatorContract,
StandardTokenMockContract,
TakerWalletWrapperContract,
TransferProxyContract,
Expand Down Expand Up @@ -52,7 +51,6 @@ contract('TakerWalletWrapper', accounts => {
let core: CoreContract;
let transferProxy: TransferProxyContract;
let vault: VaultContract;
let signatureValidator: SignatureValidatorContract;

let takerWalletWrapper: TakerWalletWrapperContract;
let components: StandardTokenMockContract[] = [];
Expand All @@ -64,8 +62,7 @@ contract('TakerWalletWrapper', accounts => {

transferProxy = await coreWrapper.deployTransferProxyAsync();
vault = await coreWrapper.deployVaultAsync();
signatureValidator = await coreWrapper.deploySignatureValidatorAsync();
core = await coreWrapper.deployCoreMockAsync(transferProxy, vault, signatureValidator);
core = await coreWrapper.deployCoreMockAsync(transferProxy, vault);
await coreWrapper.addModuleAsync(core, issuanceOrderModuleAccount);

takerWalletWrapper = await exchangeWrapper.deployTakerWalletExchangeWrapper(core.address, transferProxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
SignatureValidatorContract,
StandardTokenMockContract,
TransferProxyContract,
VaultContract,
Expand Down Expand Up @@ -58,7 +57,6 @@ contract('ZeroExExchangeWrapper', accounts => {
let core: CoreContract;
let transferProxy: TransferProxyContract;
let vault: VaultContract;
let signatureValidator: SignatureValidatorContract;

let zeroExExchangeWrapper: ZeroExExchangeWrapperContract;

Expand All @@ -71,8 +69,7 @@ contract('ZeroExExchangeWrapper', accounts => {

transferProxy = await coreWrapper.deployTransferProxyAsync();
vault = await coreWrapper.deployVaultAsync();
signatureValidator = await coreWrapper.deploySignatureValidatorAsync();
core = await coreWrapper.deployCoreMockAsync(transferProxy, vault, signatureValidator);
core = await coreWrapper.deployCoreMockAsync(transferProxy, vault);
await coreWrapper.addModuleAsync(core, issuanceOrderModuleAccount);

zeroExExchangeWrapper = await exchangeWrapper.deployZeroExExchangeWrapper(
Expand Down
5 changes: 1 addition & 4 deletions test/contracts/core/extensions/coreAccounting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
SetTokenFactoryContract,
SignatureValidatorContract,
StandardTokenMockContract,
TransferProxyContract,
VaultContract
Expand Down Expand Up @@ -47,7 +46,6 @@ contract('CoreAccounting', accounts => {
let mockTokens: StandardTokenMockContract[] = [];
let transferProxy: TransferProxyContract;
let vault: VaultContract;
let signatureValidator: SignatureValidatorContract;
let setTokenFactory: SetTokenFactoryContract;

const coreWrapper = new CoreWrapper(ownerAccount, ownerAccount);
Expand All @@ -66,8 +64,7 @@ contract('CoreAccounting', accounts => {

vault = await coreWrapper.deployVaultAsync();
transferProxy = await coreWrapper.deployTransferProxyAsync();
signatureValidator = await coreWrapper.deploySignatureValidatorAsync();
core = await coreWrapper.deployCoreAsync(transferProxy, vault, signatureValidator);
core = await coreWrapper.deployCoreAsync(transferProxy, vault);
setTokenFactory = await coreWrapper.deploySetTokenFactoryAsync(core.address);
await coreWrapper.setDefaultStateAndAuthorizationsAsync(core, vault, transferProxy, setTokenFactory);
});
Expand Down
Loading