Skip to content
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

ui: Custom VSP URL in VSP selection dialog #2529

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions client/webserver/live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1982,7 +1982,19 @@ func (c *TCore) ApproveTokenFee(assetID uint32, version uint32, approval bool) (
}

func (c *TCore) StakeStatus(assetID uint32) (*asset.TicketStakingStatus, error) {
return nil, nil
res := asset.TicketStakingStatus{
TicketPrice: 24000000000,
VotingSubsidy: 1200000,
VSP: "",
IsRPC: false,
Tickets: []*asset.Ticket{},
Stances: asset.Stances{
Agendas: []*asset.TBAgenda{},
TreasurySpends: []*asset.TBTreasurySpend{},
},
Stats: asset.TicketStats{},
}
return &res, nil
}

func (c *TCore) SetVSP(assetID uint32, addr string) error {
Expand All @@ -1998,7 +2010,14 @@ func (c *TCore) SetVotingPreferences(assetID uint32, choices, tSpendPolicy, trea
}

func (c *TCore) ListVSPs(assetID uint32) ([]*asset.VotingServiceProvider, error) {
return nil, nil
vsps := []*asset.VotingServiceProvider{
{
URL: "https://example.com",
FeePercentage: 0.1,
Voting: 12345,
},
}
return vsps, nil
}

func (c *TCore) TicketPage(assetID uint32, scanStart int32, n, skipN int) ([]*asset.Ticket, error) {
Expand Down
2 changes: 1 addition & 1 deletion client/webserver/site/src/html/bodybuilder.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{{end}}

{{define "bottom"}}
<script src="/js/entry.js?v=c57a0c0c|dce53427"></script>
<script src="/js/entry.js?v=8b29dcbe|497b4091"></script>
</body>
</html>
{{end}}
18 changes: 17 additions & 1 deletion client/webserver/site/src/html/wallets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@

{{- /* PICK A VOTING SERVICE PROVIDER */ -}}
<form id="vspPicker" class="flex-center flex-column p-2 m-4">
<div class="form-closer hoverbg">
<span class="ico-cross"></span>
</div>
<div class="fs24 sans-light">Select a Voting Service Provider</div>
<hr class="dashed my-2">
<table id="vspPickerTable">
Expand All @@ -714,7 +717,20 @@
<td data-tmpl="voting"></td>
</tr>
</tbody>
</table>{{/* TODO: ADD MANUAL INPUT */}}
</table>
<p class="mt-3">
<label for="customVspUrl">Or add custom VSP URL:</label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs translation. Add an entry for this in en-us.go.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the strings in wallets.tmpl are not localized yet. Maybe it's best to have a separate issue to cover all of those? (Probably related to/overlaps with #1454, #1880?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like just the staking related strings are not localized. I think if you wanted to do them here I think it would be fine, or it could be done in another issue as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #2544

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, every displayed string would have a translation entry, even if just en-US. But I'm as much if not more guilty than others of not doing it, so I understand and I tend to be permissive. @peterzen, I won't hold this up, but in general try to do translation and definitely do them if someone calls them out in review.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - in this one I did the l18n separately so as not to clutter the PR with changes that are unrelated to the feature.

</p>
<div class="d-flex align-items-stretch w-100">
<input
id="customVspUrl"
type="url"
class="flex-grow-1"
placeholder="https://"
aria-label="Custom VSP URL"
>
<button id="customVspSubmit" class="btn btn-outline-secondary" type="button">Add</button>
</div>
</form>

{{- /* PURCHASE TICKETS */ -}}
Expand Down
7 changes: 7 additions & 0 deletions client/webserver/site/src/js/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export default class WalletsPage extends BasePage {
Doc.bind(page.unapproveTokenSubmit, 'click', async () => { this.submitUnapproveTokenAllowance() })
Doc.bind(page.showVSPs, 'click', () => { this.showVSPPicker() })
Doc.bind(page.vspDisplay, 'click', () => { this.showVSPPicker() })
bindForm(page.vspPicker, page.customVspSubmit, async () => { this.setCustomVSP() })
Doc.bind(page.purchaseTicketsBttn, 'click', () => { this.showPurchaseTicketsDialog() })
bindForm(page.purchaseTicketsForm, page.purchaserSubmit, () => { this.purchaseTickets() })
Doc.bind(page.purchaserInput, 'change', () => { this.purchaserInputChanged() })
Expand Down Expand Up @@ -1029,6 +1030,12 @@ export default class WalletsPage extends BasePage {
this.setVSPViz(vsp.url)
}

setCustomVSP () {
const assetID = this.selectedAssetID
const vsp = { url: this.page.customVspUrl.value } as VotingServiceProvider
this.setVSP(assetID, vsp)
}

pageOfTickets (pgNum: number) {
const { stakeStatus, ticketPage } = this
let startOffset = pgNum * ticketPageSize
Expand Down