@@ -80,7 +80,7 @@ export async function createElection(
80
80
const parameter = {
81
81
description,
82
82
options,
83
- end_time : deadlineTimestamp ,
83
+ deadline : deadlineTimestamp ,
84
84
} ;
85
85
86
86
const txHash = await client . sendTransaction (
@@ -107,17 +107,15 @@ export async function getView(client, contractIndex) {
107
107
} ) ;
108
108
}
109
109
110
- export async function getVotes ( client , contractIndex , numOptions ) {
110
+ export async function getVotes ( client , contractIndex , options ) {
111
111
const promises = [ ] ;
112
112
113
113
const grpcClient = new ConcordiumGRPCClient ( client . grpcTransport ) ;
114
- for ( let i = 0 ; i < numOptions ; i ++ ) {
114
+ for ( const option of options ) {
115
115
const param = serializeUpdateContractParameters (
116
116
ContractName . fromString ( 'voting' ) ,
117
117
EntrypointName . fromString ( 'getNumberOfVotes' ) ,
118
- {
119
- vote_index : i ,
120
- } ,
118
+ option ,
121
119
toBuffer ( RAW_SCHEMA_BASE64 , 'base64' )
122
120
) ;
123
121
@@ -134,28 +132,30 @@ export async function getVotes(client, contractIndex, numOptions) {
134
132
}
135
133
136
134
export async function castVote ( client , contractIndex , vote , senderAddress ) {
137
- if ( vote === - 1 ) {
135
+ if ( ! vote ) {
138
136
window . alert ( 'Select one option.' ) ;
139
137
return ;
140
138
}
141
139
142
140
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 ;
158
143
}
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 ;
159
159
}
160
160
161
161
export default function Wallet ( props ) {
0 commit comments