Skip to content

Commit ef552c0

Browse files
author
Victor Wiebe
committed
fix: review comments addressed
1 parent 5435c1a commit ef552c0

File tree

7 files changed

+26
-84
lines changed

7 files changed

+26
-84
lines changed

src/entities/SecurityToken/Issuance/Issuance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class Issuance extends SubModule {
5252

5353
/**
5454
* Retrieve whether the issuance of tokens is allowed or not
55-
* Can be modified with `freeze`
55+
* Can be permanently frozen with `freeze`
5656
*/
5757
public allowed = async (): Promise<Boolean> => {
5858
const {

src/entities/SecurityToken/SecurityToken.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export interface Params {
2727
name: string;
2828
address: string;
2929
owner: string;
30-
tokenDetails?: string;
31-
version?: BigNumber[];
32-
granularity?: number;
33-
totalSupply?: BigNumber;
34-
currentCheckpoint?: number;
35-
treasuryWallet?: string;
30+
tokenDetails: string;
31+
version: BigNumber[];
32+
granularity: number;
33+
totalSupply: BigNumber;
34+
currentCheckpoint: number;
35+
treasuryWallet: string;
3636
}
3737

3838
export const unserialize = (serialized: string) => {

src/entities/SecurityToken/Transfers/Transfers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export class Transfers extends SubModule {
1717

1818
/**
1919
* Retrieve whether the transfer of tokens is frozen or not
20-
* Can be modified with `freeze`
20+
* Can be modified with `freeze` and `unfreeze`
2121
*/
22-
public frozen = async (): Promise<Boolean> => {
22+
public frozen = async (): Promise<boolean> => {
2323
const {
2424
context: { contractWrappers },
2525
securityToken,

src/procedures/CreateCheckpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const createRefreshSecurityTokenFactoryResolver = (
1818
return factories.securityTokenFactory.refresh(securityTokenId);
1919
};
2020

21-
export class CreateCheckpoint extends Procedure<CreateCheckpointProcedureArgs, Checkpoint | void> {
21+
export class CreateCheckpoint extends Procedure<CreateCheckpointProcedureArgs, Checkpoint> {
2222
public type = ProcedureType.CreateCheckpoint;
2323

2424
public async prepareTransactions() {

src/procedures/CreateSecurityToken.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ export class CreateSecurityToken extends Procedure<
6868
});
6969
}
7070

71-
const [usdFee, polyFee] = await securityTokenRegistry.getFees({ feeType: FeeType.StLaunchFee });
71+
const [usdFee, polyFee] = await securityTokenRegistry.getFees({
72+
feeType: FeeType.StLaunchFee,
73+
});
7274

7375
await this.addProcedure(ApproveErc20)({
7476
amount: polyFee,
@@ -86,32 +88,7 @@ export class CreateSecurityToken extends Procedure<
8688
},
8789
resolvers: [
8890
async receipt => {
89-
const { logs } = receipt;
90-
91-
const [event] = findEvents({
92-
eventName: SecurityTokenRegistryEvents.NewSecurityToken,
93-
logs,
94-
});
95-
96-
if (event) {
97-
const { args: eventArgs } = event;
98-
99-
const { _ticker, _name, _owner, _securityTokenAddress } = eventArgs;
100-
101-
return factories.securityTokenFactory.create(
102-
SecurityToken.generateId({ symbol: _ticker }),
103-
{
104-
name: _name,
105-
owner: _owner,
106-
address: _securityTokenAddress,
107-
}
108-
);
109-
}
110-
throw new PolymathError({
111-
code: ErrorCode.UnexpectedEventLogs,
112-
message:
113-
"The Security Token was successfully created but the corresponding event wasn't fired. Please report this issue to the Polymath team.",
114-
});
91+
return factories.securityTokenFactory.fetch(SecurityToken.generateId({ symbol }));
11592
},
11693
],
11794
})({

src/procedures/IssueTokens.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BigNumber } from '@polymathnetwork/contract-wrappers';
1+
import { BigNumber, TransactionParams } from '@polymathnetwork/contract-wrappers';
22
import { difference } from 'lodash';
33
import { Procedure } from './Procedure';
44
import {
@@ -20,7 +20,7 @@ export const createRefreshSecurityTokenFactoryResolver = (
2020
return factories.securityTokenFactory.refresh(securityTokenId);
2121
};
2222

23-
export class IssueTokens extends Procedure<IssueTokensProcedureArgs, Shareholder[] | void> {
23+
export class IssueTokens extends Procedure<IssueTokensProcedureArgs, Shareholder[]> {
2424
public type = ProcedureType.IssueTokens;
2525

2626
public async prepareTransactions() {
@@ -122,7 +122,10 @@ export class IssueTokens extends Procedure<IssueTokensProcedureArgs, Shareholder
122122
}
123123
const { uid: securityTokenId } = securityTokenEntity;
124124

125-
const [newShareholders] = await this.addTransaction(securityToken.issueMulti, {
125+
const [newShareholders] = await this.addTransaction<
126+
TransactionParams.SecurityToken.IssueMulti,
127+
[Shareholder[], void]
128+
>(securityToken.issueMulti, {
126129
tag: PolyTransactionTag.IssueMulti,
127130
resolvers: [
128131
async () => {

src/procedures/__tests__/CreateSecurityToken.ts

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CreateSecurityToken } from '../../procedures/CreateSecurityToken';
1010
import { Procedure } from '../../procedures/Procedure';
1111
import { Wallet } from '../../Wallet';
1212
import { PolymathError } from '../../PolymathError';
13-
import { ErrorCode, PolyTransactionTag, ProcedureType } from '../../types';
13+
import { ErrorCode, PolyTransactionTag, ProcedureType, StoType } from '../../types';
1414
import { ApproveErc20 } from '../ApproveErc20';
1515
import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory';
1616
import * as utilsModule from '../../utils';
@@ -104,64 +104,26 @@ describe('CreateSecurityToken', () => {
104104
);
105105
});
106106

107-
test('should throw if corresponding create security token event is not fired', async () => {
108-
ImportMock.mockFunction(utilsModule, 'findEvents', []);
109-
110-
// Real call
111-
const resolver = await target.prepareTransactions();
112-
113-
await expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow(
114-
new PolymathError({
115-
code: ErrorCode.UnexpectedEventLogs,
116-
message:
117-
"The Security Token was successfully created but the corresponding event wasn't fired. Please report this issue to the Polymath team.",
118-
})
119-
);
120-
});
121-
122107
test('should return the newly created security token', async () => {
123-
const creationObject = {
108+
const fakeSecurityToken = {
124109
name: () => params.name,
125110
owner: () => params.owner,
126111
address: () => params.address,
127112
};
128113

129-
const createStub = securityTokenFactoryMock.mock('create', creationObject);
130-
const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [
131-
{
132-
args: {
133-
_ticker: params.symbol,
134-
_name: params.name,
135-
_owner: params.owner,
136-
_securityTokenAddress: params.address,
137-
},
138-
},
139-
]);
114+
const fetchStub = securityTokenFactoryMock.mock('fetch', Promise.resolve(fakeSecurityToken));
140115

141116
// Real call
142117
const resolver = await target.prepareTransactions();
143118
const receipt = {} as TransactionReceiptWithDecodedLogs;
144119
await resolver.run(receipt);
145120

146121
// Verifications
147-
expect(resolver.result).toEqual(creationObject);
122+
expect(resolver.result).toEqual(fakeSecurityToken);
148123
expect(
149-
createStub
150-
.getCall(0)
151-
.calledWithExactly(SecurityToken.generateId({ symbol: params.symbol }), {
152-
name: params.name,
153-
owner: params.owner,
154-
address: params.address,
155-
})
156-
).toEqual(true);
157-
expect(createStub.callCount).toBe(1);
158-
// Verifications for findEvents
159-
expect(
160-
findEventsStub.getCall(0).calledWithMatch({
161-
eventName: SecurityTokenRegistryEvents.NewSecurityToken,
162-
})
124+
fetchStub.getCall(0).calledWithExactly(SecurityToken.generateId({ symbol: params.symbol }))
163125
).toEqual(true);
164-
expect(findEventsStub.callCount).toBe(1);
126+
expect(fetchStub.callCount).toBe(1);
165127
});
166128

167129
test('should throw error if token has been reserved by other user', async () => {

0 commit comments

Comments
 (0)