1
1
import { RedundantSubprovider , RPCSubprovider , Web3ProviderEngine } from '@0x/subproviders' ;
2
- import { PolyTokenEvents , SecurityTokenRegistryEvents } from '@polymathnetwork/abi-wrappers' ;
2
+ import { PolyTokenEvents , SecurityTokenRegistryEvents , BigNumber } from '@polymathnetwork/abi-wrappers' ;
3
3
import { ApiConstructorParams , PolymathAPI } from '../src/PolymathAPI' ;
4
4
5
5
// 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 () => {
17
17
// Instantiate the API
18
18
const polymathAPI = new PolymathAPI ( params ) ;
19
19
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' , '' ) ;
22
27
23
28
await polymathAPI . polyToken . subscribeAsync ( {
24
29
eventName : PolyTokenEvents . Approval ,
@@ -46,38 +51,15 @@ window.addEventListener('load', async () => {
46
51
47
52
const registerTicker = async ( ) => {
48
53
await polymathAPI . securityTokenRegistry . registerTicker ( {
49
- ticker,
50
- tokenName,
54
+ ticker : ticker ! ,
55
+ tokenName : tokenName ! ,
51
56
} ) ;
52
57
} ;
53
58
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
-
78
59
const tickerAvailable = await polymathAPI . securityTokenRegistry . isTickerAvailable ( {
79
- ticker : ticker ,
60
+ ticker : ticker ! ,
80
61
} ) ;
62
+
81
63
if ( tickerAvailable ) {
82
64
const tickerFee = await polymathAPI . securityTokenRegistry . getTickerRegistrationFee ( ) ;
83
65
const polyBalance = await polymathAPI . polyToken . balanceOf ( ) ;
0 commit comments