@@ -66,8 +66,6 @@ const ProjectPage: React.FC = () => {
66
66
const { ceremonyName } = useParams < RouteParams > ( ) ;
67
67
const { user, projects, setRunTutorial, runTutorial } = useContext ( StateContext ) ;
68
68
const { latestZkeys, finalBeacon, finalZkeys, hasUserContributed, projectData, isLoading, avatars, largestCircuitConstraints } = useProjectPageContext ( ) ;
69
- //const [ downloadProgress, setDownloadProgress ] = useState(0)
70
- const [ { loaded, fileSize} , setDownloadSize ] = useState ( { loaded : 0 , fileSize : 0 } )
71
69
// handle the callback from joyride
72
70
const handleJoyrideCallback = ( data : any ) => {
73
71
const { status } = data ;
@@ -143,51 +141,6 @@ const ProjectPage: React.FC = () => {
143
141
const { onCopy : copyBeaconValue , hasCopied : copiedBeaconValue } = useClipboard ( beaconValue || "" )
144
142
const { onCopy : copyBeaconHash , hasCopied : copiedBeaconHash } = useClipboard ( beaconHash || "" )
145
143
146
- let downloadProgress = fileSize > 0 ? Math . round ( 100 * loaded / fileSize ) : 0 ;
147
-
148
- // Download a file from AWS S3 bucket.
149
- const downloadFileFromS3 = ( index : number , name : string ) => {
150
- if ( finalZkeys ) {
151
- fetch ( finalZkeys [ index ] . zkeyURL , {
152
- mode : 'cors' ,
153
- headers : {
154
- 'Access-Control-Allow-Origin' :'*'
155
- } } )
156
- . then ( ( response ) => {
157
- const contentLength = response . headers . get ( 'content-length' ) ;
158
- setDownloadSize ( ( ) => { return { loaded : 0 , fileSize : parseInt ( contentLength ! , 10 ) } } ) ;
159
-
160
- const res = new Response ( new ReadableStream ( {
161
- async start ( controller ) {
162
- if ( response . body ) {
163
- const reader = response . body . getReader ( ) ;
164
- for ( ; ; ) {
165
- const { done, value} = await reader . read ( ) ;
166
- if ( done ) break ;
167
- setDownloadSize ( ds => { return { ...ds , loaded : ds . loaded + value . byteLength } } ) ;
168
- controller . enqueue ( value ) ;
169
- }
170
- controller . close ( ) ;
171
- } else {
172
- console . log ( `no body` )
173
- }
174
- }
175
- } ) ) ;
176
-
177
- res . blob ( ) . then ( ( blob ) => {
178
- console . log ( )
179
- const fileURL = window . URL . createObjectURL ( blob ) ;
180
-
181
- let alink = document . createElement ( "a" ) ;
182
- alink . href = fileURL ;
183
- alink . download = name ;
184
- alink . click ( ) ;
185
- } ) ;
186
- } ) ;
187
- }
188
-
189
- } ;
190
-
191
144
return (
192
145
< >
193
146
< HStack
@@ -602,20 +555,23 @@ const ProjectPage: React.FC = () => {
602
555
{
603
556
finalZkeys ?. map ( ( zkey , index ) => {
604
557
return (
605
- < Button
606
- margin = { "20px" }
607
- key = { index }
608
- leftIcon = { < Box as = { FaCloudDownloadAlt } w = { 3 } h = { 3 } /> }
609
- fontSize = { 12 }
610
- variant = "outline"
611
- onClick = { ( ) => downloadFileFromS3 ( index , zkey . zkeyFilename ) }
612
- fontWeight = { "regular" }
613
- isDisabled = {
614
- project ?. ceremony . data . state !== CeremonyState . FINALIZED ? true : false
615
- }
616
- >
617
- Download { zkey . zkeyFilename }
618
- </ Button >
558
+ < a
559
+ href = { zkey . zkeyURL }
560
+ key = { index }
561
+ >
562
+ < Button
563
+ margin = { "20px" }
564
+ leftIcon = { < Box as = { FaCloudDownloadAlt } w = { 3 } h = { 3 } /> }
565
+ fontSize = { 12 }
566
+ variant = "outline"
567
+ fontWeight = { "regular" }
568
+ isDisabled = {
569
+ project ?. ceremony . data . state !== CeremonyState . FINALIZED ? true : false
570
+ }
571
+ >
572
+ Download { zkey . zkeyFilename }
573
+ </ Button >
574
+ </ a >
619
575
)
620
576
} )
621
577
}
@@ -631,24 +587,27 @@ const ProjectPage: React.FC = () => {
631
587
{
632
588
latestZkeys ?. map ( ( zkey , index ) => {
633
589
return (
634
- < Button
635
- margin = { "20px" }
636
- key = { index }
637
- leftIcon = { < Box as = { FaCloudDownloadAlt } w = { 3 } h = { 3 } /> }
638
- fontSize = { 12 }
639
- variant = "outline"
640
- onClick = { ( ) => downloadFileFromS3 ( index , zkey . zkeyFilename ) }
641
- fontWeight = { "regular" }
642
- isDisabled = {
643
- project ?. ceremony . data . state !== CeremonyState . FINALIZED ? true : false
644
- }
645
- >
646
- Download { zkey . zkeyFilename }
647
- </ Button >
590
+ < a
591
+ href = { zkey . zkeyURL }
592
+ key = { index }
593
+ >
594
+ < Button
595
+ margin = { "20px" }
596
+ key = { index }
597
+ leftIcon = { < Box as = { FaCloudDownloadAlt } w = { 3 } h = { 3 } /> }
598
+ fontSize = { 12 }
599
+ variant = "outline"
600
+ fontWeight = { "regular" }
601
+ isDisabled = {
602
+ project ?. ceremony . data . state !== CeremonyState . FINALIZED ? true : false
603
+ }
604
+ >
605
+ Download { zkey . zkeyFilename }
606
+ </ Button >
607
+ </ a >
648
608
)
649
609
} )
650
610
}
651
- < Progress colorScheme = "green" value = { downloadProgress } > </ Progress >
652
611
</ >
653
612
}
654
613
0 commit comments