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

Commit 63ae095

Browse files
committed
fix: 🐛 Removed duplicate code
1 parent 1d65417 commit 63ae095

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

examples/registerTicker.ts

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RedundantSubprovider, RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
2-
import { PolyTokenEvents, SecurityTokenRegistryEvents } from '@polymathnetwork/abi-wrappers';
2+
import { PolyTokenEvents, SecurityTokenRegistryEvents, BigNumber } from '@polymathnetwork/abi-wrappers';
33
import { ApiConstructorParams, PolymathAPI } from '../src/PolymathAPI';
44

55
// This file acts as a valid sandbox.ts file in root directory for register a new Ticker on an unlocked node (like ganache)
@@ -17,8 +17,13 @@ window.addEventListener('load', async () => {
1717
// Instantiate the API
1818
const polymathAPI = new PolymathAPI(params);
1919

20-
const ticker = 'TEST';
21-
const tokenName = 'TEST TOKEN';
20+
// Get some poly tokens in your account and the security token
21+
const myAddress = await polymathAPI.getAccount();
22+
await polymathAPI.getPolyTokens({ amount: new BigNumber(1000000), address: myAddress });
23+
24+
// Prompt to setup your ticker and token name
25+
const ticker = prompt('Ticker', '');
26+
const tokenName = prompt('Token Name', '');
2227

2328
await polymathAPI.polyToken.subscribeAsync({
2429
eventName: PolyTokenEvents.Approval,
@@ -46,38 +51,15 @@ window.addEventListener('load', async () => {
4651

4752
const registerTicker = async () => {
4853
await polymathAPI.securityTokenRegistry.registerTicker({
49-
ticker,
50-
tokenName,
54+
ticker: ticker!,
55+
tokenName: tokenName!,
5156
});
5257
};
5358

54-
await polymathAPI.polyToken.subscribeAsync({
55-
eventName: PolyTokenEvents.Approval,
56-
indexFilterValues: {},
57-
callback: async (error, log) => {
58-
if (error) {
59-
console.log(error);
60-
} else {
61-
await registerTicker();
62-
}
63-
},
64-
});
65-
66-
await polymathAPI.securityTokenRegistry.subscribeAsync({
67-
eventName: SecurityTokenRegistryEvents.RegisterTicker,
68-
indexFilterValues: {},
69-
callback: async (error, log) => {
70-
if (error) {
71-
console.log(error);
72-
} else {
73-
console.log('Ticker registered!', log);
74-
}
75-
},
76-
});
77-
7859
const tickerAvailable = await polymathAPI.securityTokenRegistry.isTickerAvailable({
79-
ticker: ticker,
60+
ticker: ticker!,
8061
});
62+
8163
if (tickerAvailable) {
8264
const tickerFee = await polymathAPI.securityTokenRegistry.getTickerRegistrationFee();
8365
const polyBalance = await polymathAPI.polyToken.balanceOf();

0 commit comments

Comments
 (0)