Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 5794ca6

Browse files
committed
fix: πŸ› improve error type definitions and error messages
1 parent d3e3ce1 commit 5794ca6

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

β€Žsrc/contract_wrappers/modules/permission_manager/general_permission_manager_wrapper.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export default class GeneralPermissionManagerWrapper extends ModuleWrapper {
190190
assert.isNonZeroETHAddressHex('delegate', params.delegate);
191191
assert.assert(
192192
await (await this.contract).checkDelegate.callAsync(params.delegate),
193-
ErrorCode.InvalidDelegate,
193+
ErrorCode.NotFound,
194194
'Delegate does not exist',
195195
);
196196
return (await this.contract).deleteDelegate.sendTransactionAsync(

β€Žsrc/contract_wrappers/modules/sto/usd_tiered_sto_wrapper.tsβ€Ž

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ export default class USDTieredSTOWrapper extends STOWrapper {
770770
ErrorCode.Unauthorized,
771771
'The caller must be the ST owner',
772772
);
773-
assert.assert(!(await this.isFinalized()), ErrorCode.PreconditionRequired, 'STO is finalized');
773+
assert.assert(!(await this.isFinalized()), ErrorCode.PreconditionRequired, 'STO is already finalized');
774774
// we can't execute mint to validate the method
775775
return (await this.contract).finalize.sendTransactionAsync(params.txData, params.safetyFactor);
776776
};
@@ -906,7 +906,7 @@ export default class USDTieredSTOWrapper extends STOWrapper {
906906
'The caller must be the ST owner',
907907
);
908908
assert.isFutureDate(bigNumberToDate(await this.startTime()), 'STO already started');
909-
assert.assert(params.tokensPerTierTotal.length > 0, ErrorCode.MismatchedArrayLength, 'No tiers provided');
909+
assert.assert(params.tokensPerTierTotal.length > 0, ErrorCode.InvalidData, 'No tiers provided');
910910
assert.assert(
911911
params.ratePerTier.length === params.tokensPerTierTotal.length &&
912912
params.ratePerTierDiscountPoly.length === params.tokensPerTierTotal.length &&
@@ -1052,7 +1052,7 @@ export default class USDTieredSTOWrapper extends STOWrapper {
10521052
assert.assert(
10531053
functionsUtils.checksumAddressComparision(beneficiary, from),
10541054
ErrorCode.Unauthorized,
1055-
'Beneficiary != funder',
1055+
'Beneficiary address must be the same as sender',
10561056
);
10571057
}
10581058
const rate = await this.getRate({
@@ -1065,8 +1065,8 @@ export default class USDTieredSTOWrapper extends STOWrapper {
10651065
const minimumInvestmentUSD = await this.minimumInvestmentUSD();
10661066
assert.assert(
10671067
investedUSD.plus(investorInvestedUSD).isGreaterThan(minimumInvestmentUSD),
1068-
ErrorCode.InsufficientBalance,
1069-
'Investment < min',
1068+
ErrorCode.PreconditionRequired,
1069+
'Investment amount must be greater than the minimum investment amount',
10701070
);
10711071

10721072
const generalTMAddress = await (await this.securityTokenContract()).getModulesByName.callAsync(
@@ -1089,7 +1089,11 @@ export default class USDTieredSTOWrapper extends STOWrapper {
10891089
!nonAccreditedLimit || nonAccreditedLimit.isEqualTo(BIG_NUMBER_ZERO)
10901090
? await this.nonAccreditedLimitUSD()
10911091
: nonAccreditedLimit;
1092-
assert.assert(investorInvestedUSD.isLessThan(nonAccreditedLimitUSD), ErrorCode.ErrorLimit, 'Over investor limit');
1092+
assert.assert(
1093+
investorInvestedUSD.isLessThan(nonAccreditedLimitUSD),
1094+
ErrorCode.PreconditionRequired,
1095+
'Over investor limit',
1096+
);
10931097
}
10941098
};
10951099
}

β€Žsrc/contract_wrappers/modules/transfer_manager/blacklist_transfer_manager_wrapper.tsβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ export default class BlacklistTransferManagerWrapper extends ModuleWrapper {
820820
const blacklistInfo = await this.blacklists({ blacklistName: params.blacklistName });
821821
assert.assert(
822822
dateToBigNumber(blacklistInfo.endTime).isZero(),
823-
ErrorCode.BacklistAlreadyExist,
823+
ErrorCode.AlreadyExists,
824824
'Blacklist you are trying to add already exists',
825825
);
826826
await this.checkBlacklistTypeDetails(params);
@@ -840,7 +840,7 @@ export default class BlacklistTransferManagerWrapper extends ModuleWrapper {
840840
const blacklistDays = (params.endTime.getTime() - params.startTime.getTime()) / (1000 * 60 * 60 * 24);
841841
assert.assert(
842842
blacklistDays <= params.repeatPeriodTime,
843-
ErrorCode.TooEarly,
843+
ErrorCode.InvalidData,
844844
'The repeat period time in days must be greater than or equal to the difference between start and end time',
845845
);
846846
}
@@ -869,7 +869,7 @@ export default class BlacklistTransferManagerWrapper extends ModuleWrapper {
869869
const currentBlacklistNames = await this.getBlacklistNamesToUser({ user: params.userAddress });
870870
assert.assert(
871871
!currentBlacklistNames.includes(params.blacklistName),
872-
ErrorCode.AlreadyAdded,
872+
ErrorCode.AlreadyExists,
873873
'User already added to this blacklist name',
874874
);
875875
};

β€Žsrc/contract_wrappers/modules/transfer_manager/general_transfer_manager_wrapper.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ export default class GeneralTransferManagerWrapper extends ModuleWrapper {
555555
assert.isFutureDate(params.validTo, 'ValidTo date must be in the future');
556556
assert.assert(
557557
!(await this.nonceMap({ address: params.investor, nonce: params.nonce })),
558-
ErrorCode.AlreadyAdded,
558+
ErrorCode.AlreadyExists,
559559
'Already used signature of investor address and nonce',
560560
);
561561
return (await this.contract).modifyKYCDataSigned.sendTransactionAsync(

β€Žsrc/types.tsβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,12 @@ export enum ErrorCode {
356356
InvalidCheckpoint = 'InvalidCheckpoint',
357357
ArrayTooLarge = 'ArrayTooLarge',
358358
InvalidBound = 'InvalidBound',
359-
InvalidDelegate = 'InvalidDelegate',
360359
InsufficientAllowance = 'InsufficientAllowance',
361360
DifferentMode = 'DifferentMode',
362361
InvalidTransfer = 'InvalidTransfer',
363362
InvalidDiscount = 'InvalidDiscount',
364363
STOClosed = 'STOClosed',
365364
CoinNotAllowed = 'CoinNotAllowed',
366-
ErrorLimit = 'ErrorLimit',
367-
BacklistAlreadyExist = 'BacklistAlreadyExist',
368-
AlreadyAdded = 'AlreadyAdded',
365+
AlreadyExists = 'AlreadyExists',
366+
NotFound = 'NotFound',
369367
}

0 commit comments

Comments
Β (0)