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

Commit a54056c

Browse files
committed
fix: 🐛 implement ErrorCode in PTM
1 parent ad747f4 commit a54056c

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

src/contract_wrappers/modules/transfer_manager/percentage_transfer_manager_wrapper.ts

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
GetLogs,
2525
Perm,
2626
PERCENTAGE_DECIMALS,
27+
ErrorCode,
2728
} from '../../../types';
2829
import { parseTransferResult, valueToWei, weiToValue } from '../../../utils/convert';
2930

@@ -153,8 +154,12 @@ export default class PercentageTransferManagerWrapper extends ModuleWrapper {
153154
};
154155

155156
public unpause = async (params: TxParams) => {
156-
assert.assert(await this.paused(), 'Controller not currently paused');
157-
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
157+
assert.assert(await this.paused(), ErrorCode.PreconditionRequired, 'Controller not currently paused');
158+
assert.assert(
159+
await this.isCallerTheSecurityTokenOwner(params.txData),
160+
ErrorCode.Unauthorized,
161+
'Sender is not owner',
162+
);
158163
return (await this.contract).unpause.sendTransactionAsync(params.txData, params.safetyFactor);
159164
};
160165

@@ -163,8 +168,12 @@ export default class PercentageTransferManagerWrapper extends ModuleWrapper {
163168
};
164169

165170
public pause = async (params: TxParams) => {
166-
assert.assert(!(await this.paused()), 'Controller currently paused');
167-
assert.assert(await this.isCallerTheSecurityTokenOwner(params.txData), 'Sender is not owner');
171+
assert.assert(!(await this.paused()), ErrorCode.ContractPaused, 'Controller currently paused');
172+
assert.assert(
173+
await this.isCallerTheSecurityTokenOwner(params.txData),
174+
ErrorCode.Unauthorized,
175+
'Sender is not owner',
176+
);
168177
return (await this.contract).pause.sendTransactionAsync(params.txData, params.safetyFactor);
169178
};
170179

@@ -191,7 +200,11 @@ export default class PercentageTransferManagerWrapper extends ModuleWrapper {
191200
};
192201

193202
public changeHolderPercentage = async (params: ChangeHolderPercentageParams) => {
194-
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
203+
assert.assert(
204+
await this.isCallerAllowed(params.txData, Perm.Admin),
205+
ErrorCode.Unauthorized,
206+
'Caller is not allowed',
207+
);
195208
assert.isPercentage('maxHolderPercentage', params.maxHolderPercentage);
196209
return (await this.contract).changeHolderPercentage.sendTransactionAsync(
197210
valueToWei(params.maxHolderPercentage, PERCENTAGE_DECIMALS),
@@ -201,7 +214,11 @@ export default class PercentageTransferManagerWrapper extends ModuleWrapper {
201214
};
202215

203216
public modifyWhitelist = async (params: ModifyWhitelistParams) => {
204-
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
217+
assert.assert(
218+
await this.isCallerAllowed(params.txData, Perm.Admin),
219+
ErrorCode.Unauthorized,
220+
'Caller is not allowed',
221+
);
205222
assert.isETHAddressHex('investor', params.investor);
206223
return (await this.contract).modifyWhitelist.sendTransactionAsync(
207224
params.investor,
@@ -212,9 +229,14 @@ export default class PercentageTransferManagerWrapper extends ModuleWrapper {
212229
};
213230

214231
public modifyWhitelistMulti = async (params: ModifyWhitelistMultiParams) => {
215-
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
232+
assert.assert(
233+
await this.isCallerAllowed(params.txData, Perm.Admin),
234+
ErrorCode.Unauthorized,
235+
'Caller is not allowed',
236+
);
216237
assert.assert(
217238
params.investors.length === params.valids.length,
239+
ErrorCode.MismatchedArrayLength,
218240
'Array lengths are not equal for investors and valids',
219241
);
220242
params.investors.forEach(address => assert.isETHAddressHex('investors', address));
@@ -227,9 +249,14 @@ export default class PercentageTransferManagerWrapper extends ModuleWrapper {
227249
};
228250

229251
public setAllowPrimaryIssuance = async (params: SetAllowPrimaryIssuanceParams) => {
230-
assert.assert(await this.isCallerAllowed(params.txData, Perm.Admin), 'Caller is not allowed');
252+
assert.assert(
253+
await this.isCallerAllowed(params.txData, Perm.Admin),
254+
ErrorCode.Unauthorized,
255+
'Caller is not allowed',
256+
);
231257
assert.assert(
232258
(await this.allowPrimaryIssuance()) !== params.allowPrimaryIssuance,
259+
ErrorCode.PreconditionRequired,
233260
'AllowPrimaryIssuance value must change ',
234261
);
235262
return (await this.contract).setAllowPrimaryIssuance.sendTransactionAsync(

0 commit comments

Comments
 (0)