Skip to content

Commit 808a2d2

Browse files
committed
fix: address code review comments (cont.)
1 parent 97d6f5c commit 808a2d2

4 files changed

Lines changed: 31 additions & 14 deletions

File tree

src/LowLevel/SecurityTokenRegistry.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import {
1111
GetSecurityTokenArgs,
1212
GetTickerDetailsArgs,
1313
IsTickerAvailableArgs,
14-
TickerDetails,
1514
} from './types';
1615
import { fromWei } from './utils';
1716
import { PolymathError } from '../PolymathError';
1817
import { ErrorCodes } from '../types';
18+
import { ZERO_ADDRESS } from './constants';
1919

2020
interface SecurityTokenRegistryContract extends GenericContract {
2121
methods: {
@@ -37,6 +37,29 @@ interface SecurityTokenRegistryContract extends GenericContract {
3737
};
3838
}
3939

40+
export interface TickerDetails {
41+
/**
42+
* Owner
43+
*/
44+
0: string;
45+
/**
46+
* Registration Date
47+
*/
48+
1: string;
49+
/**
50+
* Expiry Date
51+
*/
52+
2: string;
53+
/**
54+
* Name
55+
*/
56+
3: string;
57+
/**
58+
* Registration status
59+
*/
60+
4: boolean;
61+
}
62+
4063
export class SecurityTokenRegistry extends Contract<
4164
SecurityTokenRegistryContract
4265
> {
@@ -56,9 +79,7 @@ export class SecurityTokenRegistry extends Contract<
5679
};
5780

5881
public getTickerDetails = async ({ ticker }: GetTickerDetailsArgs) => {
59-
const details = await this.contract.methods
60-
.getTickerDetails(ticker)
61-
.call({ from: this.context.account });
82+
const details = await this.contract.methods.getTickerDetails(ticker).call();
6283

6384
return details;
6485
};
@@ -78,7 +99,7 @@ export class SecurityTokenRegistry extends Contract<
7899
4: status,
79100
} = await this.getTickerDetails({ ticker });
80101
const intExpiryDate = parseInt(expiryDate);
81-
if (owner !== '0x0000000000000000000000000000000000000000') {
102+
if (owner !== ZERO_ADDRESS) {
82103
if (Date.now() > intExpiryDate * 1000 && !status) {
83104
return true;
84105
}

src/LowLevel/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const ZERO_ADDRESS: string = '0x0000000000000000000000000000000000000000';
2+
3+
export { ZERO_ADDRESS };

src/LowLevel/types.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,6 @@ export interface IsTickerAvailableArgs {
237237
ticker: string;
238238
}
239239

240-
export interface TickerDetails {
241-
0: string; // Owner
242-
1: string; // Registration Date
243-
2: string; // Expiry Date
244-
3: string; // Name
245-
4: boolean; // Registration status
246-
}
247-
248240
export enum NetworkIds {
249241
Local = 15,
250242
LocalVm = 16,

src/PolymathError.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const ErrorMessagesPerCode: {
99
'The wallet is locked, if Metamask extension is being used, the user needs to unlock it first',
1010
[ErrorCodes.UserDeniedAccess]: 'The user denied access',
1111
[ErrorCodes.TransactionRejectedByUser]: 'The user rejected the transaction',
12-
[ErrorCodes.UnexpectedReturnData]: 'Unexpected return data',
12+
[ErrorCodes.UnexpectedReturnData]:
13+
'The data returned by the smart contract has an unexpected format. Please report this issue to the Polymath team',
1314
};
1415

1516
export class PolymathError extends Error {

0 commit comments

Comments
 (0)