1-
2-
31metamaskIsInstalled ( ) ;
42
53console . log ( web3 . isConnected ( ) ) ;
64
7- var accounts , account ;
8- var myConferenceInstance ;
95abi = JSON . parse ( '[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"registrantsPaid","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"organizer","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"}],"name":"refundTicket","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newquota","type":"uint256"}],"name":"changeQuota","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"quota","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"numRegistrants","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"buyTicket","outputs":[],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_from","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Refund","type":"event"}]' ) ;
106var Conference = web3 . eth . contract ( abi ) ;
11-
12- var contractAddress = '0x8F3f14d8C8db1D544404Ab2A2273dB97740a8eb7' ;
7+ var contractAddress = '0x7fe180e63198e50057c3f2817d058e8904c650e3' ;
138var contractInstance = Conference . at ( contractAddress ) ;
14- var etherscanUrl = "https://ropsten.etherscan.io/address/0xec4e3a1ad06a2ebdc462eaf6bf361404676a441f#code" ;
9+
10+ var etherscanTxUrl = "https://etherscan.io/tx/0x57d9096861063b468194362d08cf7bffca656ea62db3c4cdaa558c124f2311db" ;
11+ var etherscanUrl = "https://etherscan.io/address/0x7fe180e63198e50057c3f2817d058e8904c650e3#code" ;
12+
13+
1514web3 . version . getNetwork ( ( err , netId ) => {
1615 switch ( netId ) {
1716 case "1" :
1817 $ ( '#network' ) . text ( "" ) ;
19- contractAddress = '0x8F3f14d8C8db1D544404Ab2A2273dB97740a8eb7 ' ;
18+ contractAddress = '0x7fe180e63198e50057c3f2817d058e8904c650e3 ' ;
2019 break ;
2120 case "2" :
2221 alert ( 'This is the deprecated Morden test network.' ) ;
2322 break ;
2423 case "3" :
2524 $ ( '#network' ) . text ( "ROPSTEN TEST NETWORK" ) ;
26- contractAddress = '0xEc4e3A1Ad06A2EbDC462eAf6Bf361404676a441F ' ;
25+ contractAddress = '0xec4e3a1ad06a2ebdc462eaf6bf361404676a441f ' ;
2726 contractInstance = Conference . at ( contractAddress ) ;
2827 etherscanTxUrl = "https://ropsten.etherscan.io/tx/0x88799ff0c66cb9e95df05f968c3a8bce86bd50c1774ba29d6eadea7138f5fa79" ;
29- etherscanUrl = "https://ropsten.etherscan.io/address/0xEc4e3A1Ad06A2EbDC462eAf6Bf361404676a441F #code" ;
28+ etherscanUrl = "https://ropsten.etherscan.io/address/0xec4e3a1ad06a2ebdc462eaf6bf361404676a441f #code" ;
3029 break ;
3130 case "4" :
3231 $ ( '#network' ) . text ( "RINKEBY TEST NETWORK" ) ;
@@ -36,8 +35,8 @@ web3.version.getNetwork((err, netId) => {
3635 $ ( '#network' ) . text ( "KOVAN TEST NETWORK" ) ;
3736 contractAddress = '0x6328426be01834de85ec0c10e3e940e629290bb1' ;
3837 contractInstance = Conference . at ( contractAddress ) ;
39- etherscanTxUrl = "https://kovan.etherscan.io/tx/0x1d5d170d9277db72d9bd81641b4c1324bfc4975ec8a9840543f0c2a091c19f96 " ;
40- etherscanUrl = "https://kovan.etherscan.io/address/0x6328426be01834de85ec0c10e3e940e629290bb1 #code" ;
38+ etherscanTxUrl = "https://kovan.etherscan.io/tx/" ;
39+ etherscanUrl = "https://kovan.etherscan.io/address/#code" ;
4140 //TODO ADD contractAddress = kovan address
4241 https://kovan.etherscan.io/address/0x6328426be01834de85ec0c10e3e940e629290bb1
4342 break ;
@@ -47,6 +46,31 @@ web3.version.getNetwork((err, netId) => {
4746 }
4847} )
4948
49+ var ticket_abi = ticket_abi = JSON . parse ( '[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"registrantsPaid","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"organizer","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"}],"name":"refundTicket","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newquota","type":"uint256"}],"name":"changeQuota","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"quota","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"numRegistrants","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"buyTicket","outputs":[],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_from","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Refund","type":"event"}]' ) ;
50+ var ticket = web3 . eth . contract ( ticket_abi ) ;
51+
52+ var decimals = undefined ;
53+ var name = undefined ;
54+ var symbol = undefined ;
55+ var allowance = undefined ;
56+ var safeLowGasPrice = setSafeLowGasPrice ( ) ;
57+ var registrantsPaid = getRegistrantsPaid ( ) ;
58+ var organizer = getOrganizer ( ) ;
59+ var numRegistrants = getNumRegistrants ( ) ;
60+ var quota = getQuota ( ) ;
61+ var ticketIsValid = true ;
62+
63+
64+ setInterval ( function ( ) {
65+ getOrganizer ( ) ;
66+ getNumRegistrants ( ) ;
67+ getQuota ( ) ;
68+ getTickets ( ) ;
69+ total = quota - numRegistrants ;
70+ setSafeLowGasPrice ( ) ;
71+ } , 1000 ) ;
72+
73+
5074function metamaskIsLocked ( ) {
5175 return web3 . eth . accounts . length == 0 ;
5276}
@@ -67,37 +91,37 @@ function metamaskIsInstalled() {
6791
6892// Initialize
6993function initializeConference ( ) {
70- Conference . web3 ( { from : accounts , gas : 3141592 } ) . then (
94+ contractInstance ( { from : accounts , gas : 3141592 } ) . then (
7195 function ( conf ) {
7296 console . log ( conf ) ;
73- myConferenceInstance = conf ;
74- $ ( "#confAddress" ) . html ( myConferenceInstance . address ) ;
97+ contractInstance = conf ;
98+ $ ( "#confAddress" ) . html ( contractInstance . address ) ;
7599 checkValues ( ) ;
76100 } ) ;
77101}
78102
79103// Check Values
80104function checkValues ( ) {
81- myConferenceInstance . quota . call ( ) . then (
105+ contractInstance . quota . call ( ) . then (
82106 function ( quota ) {
83107 $ ( "input#confQuota" ) . val ( quota ) ;
84- return myConferenceInstance . organizer . call ( ) ;
108+ return contractInstance . organizer . call ( ) ;
85109 } ) . then (
86110 function ( organizer ) {
87111 $ ( "input#confOrganizer" ) . val ( organizer ) ;
88- return myConferenceInstance . numRegistrants . call ( ) ;
112+ return contractInstance . numRegistrants . call ( ) ;
89113 } ) . then (
90114 function ( num ) {
91115 $ ( "#numRegistrants" ) . html ( num . toNumber ( ) ) ;
92- return myConferenceInstance . organizer . call ( ) ;
116+ return contractInstance . organizer . call ( ) ;
93117 } ) ;
94118}
95119
96120// Change Quota
97121function changeQuota ( val ) {
98- myConferenceInstance . changeQuota ( val , { from : accounts } ) . then (
122+ contractInstance . changeQuota ( val , { from : accounts } ) . then (
99123 function ( ) {
100- return myConferenceInstance . quota . call ( ) ;
124+ return contractInstance . quota . call ( ) ;
101125 } ) . then (
102126 function ( quota ) {
103127 if ( quota == val ) {
@@ -113,13 +137,13 @@ function changeQuota(val) {
113137// buyTicket
114138function buyTicket ( buyerAddress , ticketPrice ) {
115139
116- myConferenceInstance . buyTicket ( { from : buyerAddress , value : ticketPrice } ) . then (
140+ contractInstance . buyTicket ( { from : buyerAddress , value : ticketPrice } ) . then (
117141 function ( ) {
118- return myConferenceInstance . numRegistrants . call ( ) ;
142+ return contractInstance . numRegistrants . call ( ) ;
119143 } ) . then (
120144 function ( num ) {
121145 $ ( "#numRegistrants" ) . html ( num . toNumber ( ) ) ;
122- return myConferenceInstance . registrantsPaid . call ( buyerAddress ) ;
146+ return contractInstance . registrantsPaid . call ( buyerAddress ) ;
123147 } ) . then (
124148 function ( valuePaid ) {
125149 var msgResult ;
@@ -137,19 +161,19 @@ function refundTicket(buyerAddress, ticketPrice) {
137161
138162 var msgResult ;
139163
140- myConferenceInstance . registrantsPaid . call ( buyerAddress ) . then (
164+ contractInstance . registrantsPaid . call ( buyerAddress ) . then (
141165 function ( result ) {
142166 if ( result . toNumber ( ) == 0 ) {
143167 $ ( "#refundTicketResult" ) . html ( "Buyer is not registered - no refund!" ) ;
144168 } else {
145- myConferenceInstance . refundTicket ( buyerAddress ,
169+ contractInstance . refundTicket ( buyerAddress ,
146170 ticketPrice , { from : accounts [ 0 ] } ) . then (
147171 function ( ) {
148- return myConferenceInstance . numRegistrants . call ( ) ;
172+ return contractInstance . numRegistrants . call ( ) ;
149173 } ) . then (
150174 function ( num ) {
151175 $ ( "#numRegistrants" ) . html ( num . toNumber ( ) ) ;
152- return myConferenceInstance . registrantsPaid . call ( buyerAddress ) ;
176+ return contractInstance . registrantsPaid . call ( buyerAddress ) ;
153177 } ) . then (
154178 function ( valuePaid ) {
155179 if ( valuePaid . toNumber ( ) == 0 ) {
0 commit comments