@@ -80,7 +80,7 @@ export async function createElection(
8080 const parameter = {
8181 description,
8282 options,
83- end_time : deadlineTimestamp ,
83+ deadline : deadlineTimestamp ,
8484 } ;
8585
8686 const txHash = await client . sendTransaction (
@@ -107,17 +107,15 @@ export async function getView(client, contractIndex) {
107107 } ) ;
108108}
109109
110- export async function getVotes ( client , contractIndex , numOptions ) {
110+ export async function getVotes ( client , contractIndex , options ) {
111111 const promises = [ ] ;
112112
113113 const grpcClient = new ConcordiumGRPCClient ( client . grpcTransport ) ;
114- for ( let i = 0 ; i < numOptions ; i ++ ) {
114+ for ( const option of options ) {
115115 const param = serializeUpdateContractParameters (
116116 ContractName . fromString ( 'voting' ) ,
117117 EntrypointName . fromString ( 'getNumberOfVotes' ) ,
118- {
119- vote_index : i ,
120- } ,
118+ option ,
121119 toBuffer ( RAW_SCHEMA_BASE64 , 'base64' )
122120 ) ;
123121
@@ -134,28 +132,30 @@ export async function getVotes(client, contractIndex, numOptions) {
134132}
135133
136134export async function castVote ( client , contractIndex , vote , senderAddress ) {
137- if ( vote === - 1 ) {
135+ if ( ! vote ) {
138136 window . alert ( 'Select one option.' ) ;
139137 return ;
140138 }
141139
142140 const connectedToTestnet = await checkConnectedToTestnet ( client ) ;
143- if ( connectedToTestnet ) {
144- const txHash = await client . sendTransaction (
145- senderAddress ,
146- AccountTransactionType . Update ,
147- {
148- amount : CcdAmount . fromMicroCcd ( BigInt ( 0 ) ) ,
149- address : { index : BigInt ( contractIndex ) , subindex : BigInt ( 0 ) } ,
150- receiveName : 'voting.vote' ,
151- maxContractExecutionEnergy : BigInt ( 30000 ) ,
152- } ,
153- { vote_index : vote } ,
154- RAW_SCHEMA_BASE64
155- ) ;
156- console . log ( { txHash } ) ;
157- return txHash ;
141+ if ( ! connectedToTestnet ) {
142+ return ;
158143 }
144+
145+ const txHash = await client . sendTransaction (
146+ senderAddress ,
147+ AccountTransactionType . Update ,
148+ {
149+ amount : CcdAmount . fromMicroCcd ( BigInt ( 0 ) ) ,
150+ address : { index : BigInt ( contractIndex ) , subindex : BigInt ( 0 ) } ,
151+ receiveName : 'voting.vote' ,
152+ maxContractExecutionEnergy : BigInt ( 30000 ) ,
153+ } ,
154+ vote ,
155+ RAW_SCHEMA_BASE64
156+ ) ;
157+ console . log ( { txHash } ) ;
158+ return txHash ;
159159}
160160
161161export default function Wallet ( props ) {
0 commit comments