Skip to content

Commit

Permalink
Added custom VSP URL input to VSP picker.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzen committed Sep 17, 2023
1 parent bf4887e commit d2ed286
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
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=faadd923|2e83f47d"></script>
<script src="/js/entry.js?v=194f4df2|f15de5ff"></script>
</body>
</html>
{{end}}
23 changes: 22 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,25 @@
<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>
</p>
<div class="input-group has-validation">
<input
id="customVspUrl"
type="url"
class="form-control"
placeholder="https://"
aria-label="Custom VSP URL"
/>
<div class="input-group-append">
<button
id="customVspSubmit"
class="btn btn-outline-secondary"
type="button">Add</button>
</div>
</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)
}

async 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

0 comments on commit d2ed286

Please sign in to comment.