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

Improve copy button position #1033

Merged
merged 28 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6e43ad9
fix tooltip placement for elements on banner left
madalin0b Aug 30, 2021
fb1e46d
add copy button validators page table
madalin0b Aug 31, 2021
b6fc997
add copy button to format public key function
madalin0b Aug 31, 2021
d4b3e64
add copy button
madalin0b Aug 31, 2021
7c7003f
Stripe Premium (#1015)
manuelsc Aug 31, 2021
ded7568
Merge branch 'master' into add-copy-btn
madalin0b Aug 31, 2021
ba46b35
fix premium settings indicater when purchased via ios, fix authorize …
manuelsc Aug 31, 2021
6528f97
add copy button in progress
madalin0b Aug 31, 2021
e16d19a
Merge branch 'master' into add-copy-btn
madalin0b Aug 31, 2021
908b9da
fix docs (#1022)
qu0b Aug 31, 2021
a3dbb68
Revert/premium (#1023)
qu0b Aug 31, 2021
0a36b38
Merge branch 'master' into add-copy-btn
madalin0b Sep 1, 2021
c23bc5b
copy button added
madalin0b Sep 1, 2021
ffd8512
reduce button padding
madalin0b Sep 1, 2021
dc96736
Stripemobileapifix (#1024)
manuelsc Sep 1, 2021
32484b3
small fixes
madalin0b Sep 1, 2021
12f5293
Merge branch 'master' into add-copy-btn
madalin0b Sep 1, 2021
a2b8050
make whale color more visible on dark theme (#1025)
manuelsc Sep 1, 2021
2bc837f
Merge branch 'master' into add-copy-btn
madalin0b Sep 1, 2021
c521817
ec changes for stripe premium, rel link on hero to /mobile, navbar us…
manuelsc Sep 2, 2021
d85bb0c
Merge branch 'master' into add-copy-btn
madalin0b Sep 2, 2021
9e18c1e
copy button positioning fix
madalin0b Sep 2, 2021
237ea77
Merge branch 'office/staging' of https://github.com/gobitfly/eth2-bea…
madalin0b Sep 2, 2021
12f4f1d
rpc-lighthouse: fix exporting of older epochs (#1032)
guybrush Sep 2, 2021
bb05ba1
Merge branch 'master' into add-copy-btn
madalin0b Sep 2, 2021
3f8118a
improve copy button position
madalin0b Sep 3, 2021
f579830
Merge branch 'office/staging' of https://github.com/gobitfly/eth2-bea…
madalin0b Sep 3, 2021
8f6b3ce
Merge branch 'add-copy-btn' into branch-for-pr-staging
madalin0b Sep 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 70 additions & 1 deletion rpc/lighthouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,37 @@ func (lc *LighthouseClient) GetEpochData(epoch uint64) (*types.EpochData, error)
return nil, fmt.Errorf("error parsing epoch validators: %v", err)
}

epoch1d := int64(epoch) - 225
if epoch1d < 0 {
epoch1d = 0
}
start := time.Now()
validatorBalances1d, err := lc.getBalancesForEpoch(epoch1d)
if err != nil {
return nil, err
}
logger.Printf("retrieved data for %v validator balances for epoch %v (1d) took %v", len(parsedValidators.Data), epoch1d, time.Since(start))
epoch7d := int64(epoch) - 225*7
if epoch7d < 0 {
epoch7d = 0
}
start = time.Now()
validatorBalances7d, err := lc.getBalancesForEpoch(epoch7d)
if err != nil {
return nil, err
}
logger.Printf("retrieved data for %v validator balances for epoch %v (7d) took %v", len(parsedValidators.Data), epoch7d, time.Since(start))
start = time.Now()
epoch31d := int64(epoch) - 225*31
if epoch31d < 0 {
epoch31d = 0
}
validatorBalances31d, err := lc.getBalancesForEpoch(epoch31d)
if err != nil {
return nil, err
}
logger.Printf("retrieved data for %v validator balances for epoch %v (31d) took %v", len(parsedValidators.Data), epoch31d, time.Since(start))

for _, validator := range parsedValidators.Data {
data.Validators = append(data.Validators, &types.Validator{
Index: uint64(validator.Index),
Expand All @@ -270,6 +301,9 @@ func (lc *LighthouseClient) GetEpochData(epoch uint64) (*types.EpochData, error)
ActivationEpoch: uint64(validator.Validator.ActivationEpoch),
ExitEpoch: uint64(validator.Validator.ExitEpoch),
WithdrawableEpoch: uint64(validator.Validator.WithdrawableEpoch),
Balance1d: validatorBalances1d[uint64(validator.Index)],
Balance7d: validatorBalances7d[uint64(validator.Index)],
Balance31d: validatorBalances31d[uint64(validator.Index)],
})
}

Expand Down Expand Up @@ -380,6 +414,34 @@ func uint64List(li []uint64Str) []uint64 {
return out
}

func (lc *LighthouseClient) getBalancesForEpoch(epoch int64) (map[uint64]uint64, error) {

if epoch < 0 {
epoch = 0
}

var err error

validatorBalances := make(map[uint64]uint64)

resp, err := lc.get(fmt.Sprintf("%s/eth/v1/beacon/states/%d/validator_balances", lc.endpoint, epoch*int64(utils.Config.Chain.SlotsPerEpoch)))
if err != nil {
return validatorBalances, err
}

var parsedResponse StandardValidatorBalancesResponse
err = json.Unmarshal(resp, &parsedResponse)
if err != nil {
return nil, fmt.Errorf("error parsing response for validator_balances")
}

for _, b := range parsedResponse.Data {
validatorBalances[uint64(b.Index)] = uint64(b.Balance)
}

return validatorBalances, nil
}

// GetBlocksBySlot will get the blocks by slot from Lighthouse RPC api
func (lc *LighthouseClient) GetBlocksBySlot(slot uint64) ([]*types.Block, error) {
respRoot, err := lc.get(fmt.Sprintf("%s/eth/v1/beacon/blocks/%d/root", lc.endpoint, slot))
Expand Down Expand Up @@ -604,7 +666,7 @@ func (lc *LighthouseClient) GetFinalityCheckpoints(epoch uint64) (*types.Finalit
var notFoundErr = errors.New("not found 404")

func (lc *LighthouseClient) get(url string) ([]byte, error) {
client := &http.Client{Timeout: time.Second * 60}
client := &http.Client{Timeout: time.Second * 120}

resp, err := client.Get(url)
if err != nil {
Expand Down Expand Up @@ -891,3 +953,10 @@ type StandardSyncingResponse struct {
SyncDistance uint64Str `json:"sync_distance"`
} `json:"data"`
}

type StandardValidatorBalancesResponse struct {
Data []struct {
Index uint64Str `json:"index"`
Balance uint64Str `json:"balance"`
} `json:"data"`
}
1 change: 1 addition & 0 deletions static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ $(document).ready(function() {
data: '0',
createdCell: function(td, cellData, rowData, row, col) {
$(td).css('display', 'flex');
$(td).css('align-items', 'center');
$(td).css('justify-content', 'space-between');
},
render: function(data, type, row, meta) {
Expand Down
2 changes: 1 addition & 1 deletion templates/epoch.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ <h1 class="h4 mb-1 mb-md-0">
<td aria-ethereum-date="{{.Ts.Unix}}"
aria-ethereum-date-format="FROMNOW">{{.Ts.Format "2006-01-02T15:04:05"}}</td>
<td><a href="/validator/{{.Proposer}}">{{formatAddCommas .Proposer}}</a></td>
<td class="text-monospace">
<td class="d-flex align-items-center text-monospace">
{{if eq .Status 1}}
<a href="/block/{{printf "%x" .BlockRoot}}">0x{{printf "%.4x" .BlockRoot}}...</a>
<i style="padding: .25rem;" class="fa fa-copy text-muted" role="button" data-toggle="tooltip" title="Copy to clipboard" data-clipboard-text=0x{{printf "%x" .BlockRoot}}></i>
Expand Down
1 change: 1 addition & 0 deletions templates/poap.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
data: '0',
createdCell: function(td, cellData, rowData, row, col) {
$(td).css('display', 'flex');
$(td).css('align-items', 'center');
$(td).css('justify-content', 'space-between');
},
render: function(data, type, row) {
Expand Down
1 change: 1 addition & 0 deletions templates/validators.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ <h6 class="dropdown-header"><span>Filter state</span> <span><span class="text-su
data: '0',
createdCell: function(td, cellData, rowData, row, col) {
$(td).css('display', 'flex');
$(td).css('align-items', 'center');
$(td).css('justify-content', 'space-between');
},
render: function(data, type, row, meta) {
Expand Down
4 changes: 2 additions & 2 deletions utils/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ func FormatHash(hash []byte) template.HTML {
// }
// return template.HTML(fmt.Sprintf("<span class=\"text-monospace\">0x%x</span>", hash))
if len(hash) > 3 {
return template.HTML(fmt.Sprintf("<div class=\"d-inline mr-4 mr-lg-0\" style=\"position: relative;\"><span style=\"display: inline-block; width: 60px;\" class=\"text-monospace\">%#x…</span><i onclick=\"event.preventDefault()\" style=\"position: relative; left: 25px; padding: .25rem;\" class=\"fa fa-copy text-muted\" role=\"button\" data-toggle=\"tooltip\" title=\"Copy to clipboard\" data-clipboard-text=0x%x></i></div>", hash[:3], hash))
return template.HTML(fmt.Sprintf("<div class=\"d-inline mr-4 mr-lg-0\" style=\"position: relative;\"><span style=\"display: inline-block; width: 2.4rem;\" class=\"text-monospace\">%#x…</span><i onclick=\"event.preventDefault()\" style=\"position: relative; left: 2.6rem; padding: .25rem;\" class=\"fa fa-copy text-muted\" role=\"button\" data-toggle=\"tooltip\" title=\"Copy to clipboard\" data-clipboard-text=0x%x></i></div>", hash[:3], hash))
}
return template.HTML(fmt.Sprintf("<div class=\"d-inline mr-4 mr-lg-0\" style=\"position: relative;\"><span style=\"display: inline-block; width: 60px;\" class=\"text-monospace\">%#x…</span><i onclick=\"event.preventDefault()\" style=\"position: relative; left: 25px; padding: .25rem;\" class=\"fa fa-copy text-muted\" role=\"button\" data-toggle=\"tooltip\" title=\"Copy to clipboard\" data-clipboard-text=0x%x></i></div>", hash, hash))
return template.HTML(fmt.Sprintf("<div class=\"d-inline mr-4 mr-lg-0\" style=\"position: relative;\"><span style=\"display: inline-block; width: 2.4rem;\" class=\"text-monospace\">%#x…</span><i onclick=\"event.preventDefault()\" style=\"position: relative; left: 2.6rem; padding: .25rem;\" class=\"fa fa-copy text-muted\" role=\"button\" data-toggle=\"tooltip\" title=\"Copy to clipboard\" data-clipboard-text=0x%x></i></div>", hash, hash))
}

func FormatBitlist(bits []byte) template.HTML {
Expand Down