Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Shoren reason stings
Browse files Browse the repository at this point in the history
  • Loading branch information
felix2feng committed Feb 21, 2019
1 parent 5470553 commit 7fcfe64
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 37 deletions.
12 changes: 6 additions & 6 deletions contracts/core/extensions/CoreAccounting.sol
Expand Up @@ -199,19 +199,19 @@ contract CoreAccounting is
// Confirm and empty _tokens array is not passed
require(
_tokens.length > 0,
"Core.batchDeposit: Empty tokens array"
"Core: Empty tokens"
);

// Confirm an empty _quantities array is not passed
require(
_quantities.length > 0,
"Core.batchDeposit: Empty quantities array"
"Core: Empty quantities"
);

// Confirm there is one quantity for every token address
require(
_tokens.length == _quantities.length,
"Core.batchDeposit: Tokens and quantities lengths mismatch"
"Core: Tokens + quantities len mismatch"
);

state.transferProxyInstance.batchTransfer(
Expand Down Expand Up @@ -248,19 +248,19 @@ contract CoreAccounting is
// Confirm an empty _tokens array is not passed
require(
_tokens.length > 0,
"Core.batchWithdraw: Empty tokens array"
"Core: Empty tokens"
);

// Confirm an empty _quantities array is not passed
require(
_quantities.length > 0,
"Core.batchWithdraw: Empty quantities array"
"Core: Empty quantities"
);

// Confirm there is one quantity for every token address
require(
_tokens.length == _quantities.length,
"Core.batchWithdraw: Tokens and quantities lengths mismatch"
"Core: Tokens + quantities len mismatch"
);

// Call Vault contract to deattribute withdrawn tokens from user
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/extensions/CoreFactory.sol
Expand Up @@ -70,7 +70,7 @@ contract CoreFactory is
// Verify Factory is linked to Core
require(
state.validFactories[_factory],
"Core.create: Invalid or disabled factory address"
"Core: Invalid factory"
);

// Create the Set
Expand Down
16 changes: 8 additions & 8 deletions contracts/core/extensions/CoreInternal.sol
Expand Up @@ -118,7 +118,7 @@ contract CoreInternal is
{
require(
state.validFactories[_factory],
"CoreInternal.removeFactory: Factory not enabled"
"Core: Factory not enabled"
);

state.factories = state.factories.remove(_factory);
Expand Down Expand Up @@ -147,7 +147,7 @@ contract CoreInternal is
{
require(
state.exchangeIds[_exchangeId] == address(0),
"CoreInternal.removeExchange: Exchange Id not registered"
"Core: Exchange Id not registered"
);

state.exchangeIds[_exchangeId] = _exchange;
Expand Down Expand Up @@ -176,12 +176,12 @@ contract CoreInternal is
{
require(
state.exchangeIds[_exchangeId] != address(0),
"CoreInternal.removeExchange: Exchange already removed"
"Core: Exchange already removed"
);

require(
state.exchangeIds[_exchangeId] == _exchange,
"CoreInternal.removeExchange: ExchangeId does not matched passed exchange"
"Core: ExchangeId != exchange"
);

state.exchanges = state.exchanges.remove(_exchange);
Expand Down Expand Up @@ -229,7 +229,7 @@ contract CoreInternal is
{
require(
state.validModules[_module],
"CoreInternal.removeModule: Module not enabled"
"Core: Module not enabled"
);

state.modules = state.modules.remove(_module);
Expand All @@ -255,7 +255,7 @@ contract CoreInternal is
{
require(
state.validSets[_set],
"CoreInternal.disableSet: Set not enabled"
"Core: Set not enabled"
);

state.setTokens = state.setTokens.remove(_set);
Expand Down Expand Up @@ -283,7 +283,7 @@ contract CoreInternal is
{
require(
state.disabledSets[_set],
"CoreInternal.reenableSet: Set not disabled"
"Core: Set not disabled"
);

state.setTokens = state.setTokens.append(_set);
Expand Down Expand Up @@ -333,7 +333,7 @@ contract CoreInternal is
{
require(
state.validPriceLibraries[_priceLibrary],
"CoreInternal.removePriceLibrary: PriceLibrary not enabled"
"Core: PriceLibrary not enabled"
);

state.priceLibraries = state.priceLibraries.remove(_priceLibrary);
Expand Down
12 changes: 6 additions & 6 deletions contracts/core/extensions/CoreIssuance.sol
Expand Up @@ -155,13 +155,13 @@ contract CoreIssuance is
// Verify Set was created by Core and is enabled
require(
state.validSets[_set],
"Core.redeemAndWithdraw: Invalid or disabled SetToken address"
"Core: Invalid SetToken"
);

// Validate quantity is multiple of natural unit
require(
_quantity % setToken.naturalUnit() == 0,
"Core.redeemAndWithdraw: Quantity must be multiple of natural unit"
"Core: Quantity must be multiple of natural unit"
);

// Burn the Set token (thereby decrementing the SetToken balance)
Expand Down Expand Up @@ -287,7 +287,7 @@ contract CoreIssuance is
// Verify Set was created by Core and is enabled
require(
state.validSets[_set],
"Core.issue: Invalid or disabled SetToken address"
"Core: Invalid SetToken"
);

// Declare interface variables
Expand All @@ -296,7 +296,7 @@ contract CoreIssuance is
// Validate quantity is multiple of natural unit
require(
_quantity % setToken.naturalUnit() == 0,
"Core.issue: Quantity must be multiple of natural unit"
"Core: Quantity must be multiple of natural unit"
);

// Fetch set token properties
Expand Down Expand Up @@ -401,7 +401,7 @@ contract CoreIssuance is
// Verify Set was created by Core and is enabled
require(
state.validSets[_set],
"Core.redeem: Invalid or disabled SetToken address"
"Core: Invalid SetToken address"
);

// Declare interface variables
Expand All @@ -411,7 +411,7 @@ contract CoreIssuance is
uint256 naturalUnit = setToken.naturalUnit();
require(
_quantity % naturalUnit == 0,
"Core.redeem: Quantity must be multiple of natural unit"
"Core: Quantity must be multiple of natural unit"
);

// Burn the Set token (thereby decrementing the SetToken balance)
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/extensions/CoreOperationState.sol
Expand Up @@ -60,7 +60,7 @@ contract CoreOperationState is
modifier whenOperational() {
require(
state.operationState == uint8(OperationState.Operational),
"CoreOperationalState.whenOperational: Function is in non-operational state."
"Core: State is non-operational"
);
_;
}
Expand Down
4 changes: 4 additions & 0 deletions migrations/3_core.js
Expand Up @@ -3,6 +3,7 @@ const Core = artifacts.require("Core");
const ERC20Wrapper = artifacts.require('ERC20Wrapper');
const ExchangeIssueLibrary = artifacts.require('ExchangeIssueLibrary');
const ExchangeIssueModule = artifacts.require('ExchangeIssueModule');
const IssuanceLibrary = artifacts.require('IssuanceLibrary');
const KyberNetworkWrapper = artifacts.require('KyberNetworkWrapper');
const LinearAuctionPriceCurve = artifacts.require('LinearAuctionPriceCurve');
const PayableExchangeIssue = artifacts.require("PayableExchangeIssue");
Expand Down Expand Up @@ -78,6 +79,9 @@ async function deployAndLinkLibraries(deployer, network) {
await ZeroExExchangeWrapper.link('ERC20Wrapper', ERC20Wrapper.address);
await PayableExchangeIssue.link('ERC20Wrapper', ERC20Wrapper.address);

await deployer.deploy(IssuanceLibrary);
await Core.link('IssuanceLibrary', IssuanceLibrary.address);

await deployer.deploy(ExchangeIssueLibrary);
await PayableExchangeIssue.link('ExchangeIssueLibrary', ExchangeIssueLibrary.address);

Expand Down
46 changes: 31 additions & 15 deletions test/contracts/core/extensions/coreModuleInteraction.spec.ts
Expand Up @@ -988,19 +988,35 @@ contract('CoreModuleInteraction', accounts => {
});
});

// describe('#batchIncrementTokenOwnerModule', async () => {
// let subjectTokens: Address[];
// let subjectOwner: Address;
// let subjectQuantities: BigNumber[];
// let subjectCaller: Address;

// async function subject(): Promise<string> {
// return core.batchIncrementTokenOwnerModule.sendTransactionAsync(
// subjectTokens,
// subjectOwner,
// subjectQuantities,
// { from: subjectCaller },
// );
// }
// });
describe('#batchIncrementTokenOwnerModule', async () => {
let subjectTokens: Address[];
let subjectOwner: Address;
let subjectQuantities: BigNumber[];
let subjectCaller: Address;

beforeEach(async () => {
subjectTokens = (await erc20Wrapper.deployTokensAsync(2, ownerAccount)).map(token => token.address);
subjectOwner = otherAccount;
subjectQuantities = [new BigNumber(10), new BigNumber(20)];
subjectCaller = moduleAccount;
});

async function subject(): Promise<string> {
return core.batchIncrementTokenOwnerModule.sendTransactionAsync(
subjectTokens,
subjectOwner,
subjectQuantities,
{ from: subjectCaller },
);
}

it('should increment the balances of the tokens properly', async () => {
await subject();
});

describe('when the caller is not an authorized module', async () => {

});

});
});

0 comments on commit 7fcfe64

Please sign in to comment.