@@ -127,6 +127,62 @@ func (api *PrivateExtensionAPI) doMultiTenantChecks(ctx context.Context, address
127127 return nil
128128}
129129
130+ // GenerateExtensionApprovalUuid generates a uuid to be used for contract state extension approval when calling doVote within the management contract,
131+ // allowing the approval method to be called with an external signer
132+ func (api * PrivateExtensionAPI ) GenerateExtensionApprovalUuid (ctx context.Context , addressToVoteOn common.Address , externalSignerAddress common.Address , txa ethapi.SendTxArgs ) (string , error ) {
133+ err := api .doMultiTenantChecks (ctx , txa .From , txa )
134+ if err != nil {
135+ return "" , err
136+ }
137+
138+ psm , err := api .privacyService .apiBackendHelper .PSMR ().ResolveForUserContext (ctx )
139+ if err != nil {
140+ return "" , err
141+ }
142+ psi := psm .ID
143+
144+ // check if the extension has been completed. if yes
145+ // no acceptance required
146+ status , err := api .checkIfExtensionComplete (addressToVoteOn , externalSignerAddress , psi )
147+ if err != nil {
148+ return "" , err
149+ }
150+
151+ if status {
152+ return "" , errors .New ("contract extension process complete. nothing to accept" )
153+ }
154+
155+ // get all participants for the contract being extended
156+ participants , err := api .privacyService .GetAllParticipants (api .privacyService .stateFetcher .getCurrentBlockHash (), addressToVoteOn , psi )
157+ if err == nil {
158+ txa .PrivateFor = append (txa .PrivateFor , participants ... )
159+ }
160+
161+ txArgs , err := api .privacyService .GenerateTransactOptions (txa )
162+ if err != nil {
163+ return "" , err
164+ }
165+
166+ psiManagementContractClient := api .privacyService .managementContract (psi )
167+ defer psiManagementContractClient .Close ()
168+ voterList , err := psiManagementContractClient .GetAllVoters (addressToVoteOn )
169+ if err != nil {
170+ return "" , err
171+ }
172+ if isVoter := checkAddressInList (externalSignerAddress , voterList ); ! isVoter {
173+ return "" , errNotAcceptor
174+ }
175+
176+ if api .checkAlreadyVoted (addressToVoteOn , externalSignerAddress , psi ) {
177+ return "" , errors .New ("already voted" )
178+ }
179+ uuid , err := generateUuid (addressToVoteOn , txArgs .PrivateFrom , txArgs .PrivateFor , api .privacyService .ptm )
180+ if err != nil {
181+ return "" , err
182+ }
183+ return uuid , nil
184+ }
185+
130186// ApproveContractExtension submits the vote to the specified extension management contract. The vote indicates whether to extend
131187// a given contract to a new participant or not
132188func (api * PrivateExtensionAPI ) ApproveExtension (ctx context.Context , addressToVoteOn common.Address , vote bool , txa ethapi.SendTxArgs ) (string , error ) {
0 commit comments