-
Notifications
You must be signed in to change notification settings - Fork 39
Upgrade dcrwallet to master branch (future version v4) #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
b87f8d5
5e1eee9
5f2fb01
860029e
b980746
c92100a
000de69
ccb3b21
e812b40
60d8e04
e431d1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,7 @@ import ( | |
| "sort" | ||
| "strings" | ||
|
|
||
| "decred.org/dcrwallet/v3/errors" | ||
| w "decred.org/dcrwallet/v3/wallet" | ||
| "decred.org/dcrwallet/v4/errors" | ||
|
|
||
| "github.com/crypto-power/cryptopower/libwallet/utils" | ||
| "github.com/decred/dcrd/chaincfg/chainhash" | ||
|
|
@@ -111,22 +110,19 @@ func (asset *Asset) SetVoteChoice(agendaID, choiceID, hash, passphrase string) e | |
| return err | ||
| } | ||
|
|
||
| currentChoice := w.AgendaChoice{ | ||
| AgendaID: agendaID, | ||
| ChoiceID: "abstain", // default to abstain as current choice if not found in wallet | ||
| choice, ok := choices[agendaID] | ||
dmigwi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if ok && choice == strings.ToLower(choiceID) { | ||
| // Do not set the same choice again | ||
| return nil | ||
| } | ||
|
|
||
| for i := range choices { | ||
| if choices[i].AgendaID == agendaID { | ||
| currentChoice.ChoiceID = choices[i].ChoiceID | ||
| break | ||
| } | ||
| if !ok { | ||
| // Default to abstain if no previous choice existed | ||
| choice = "abstain" | ||
| } | ||
|
|
||
| newChoice := w.AgendaChoice{ | ||
| AgendaID: agendaID, | ||
| ChoiceID: strings.ToLower(choiceID), | ||
| } | ||
| currentChoice := map[string]string{agendaID: choice} | ||
| newChoice := map[string]string{agendaID: strings.ToLower(choiceID)} | ||
dmigwi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| _, err = asset.Internal().DCR.SetAgendaChoices(ctx, ticketHash, newChoice) | ||
| if err != nil { | ||
|
|
@@ -181,7 +177,7 @@ func (asset *Asset) SetVoteChoice(agendaID, choiceID, hash, passphrase string) e | |
| firstErr = err | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the new dcrwallet commits since
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be done app wide so a separate issue can best address this. |
||
| continue // try next tHash | ||
| } | ||
| err = vspClient.SetVoteChoice(ctx, tHash, []w.AgendaChoice{newChoice}, nil, nil) | ||
| err = vspClient.SetVoteChoice(ctx, tHash, newChoice, nil, nil) | ||
| if err != nil && firstErr == nil { | ||
| firstErr = err | ||
| continue // try next tHash | ||
|
|
@@ -245,9 +241,9 @@ func (asset *Asset) AllVoteAgendas(hash string, newestFirst bool) ([]*Agenda, er | |
| d := &deployments[i] | ||
|
|
||
| votingPreference := "abstain" // assume abstain, if we have the saved pref, it'll be updated below | ||
| for c := range choices { | ||
| if choices[c].AgendaID == d.Vote.Id { | ||
| votingPreference = choices[c].ChoiceID | ||
| for agendaID, choiceID := range choices { | ||
| if agendaID == d.Vote.Id { | ||
| votingPreference = choiceID | ||
| break | ||
| } | ||
| } | ||
|
Comment on lines
+244
to
249
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This look correct?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is double query; during the map for loop, |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.