Skip to content

Commit

Permalink
Merge pull request ethereum#19 from maticnetwork/dev-span-sprint-api-…
Browse files Browse the repository at this point in the history
…calls

Dev span sprint api calls
  • Loading branch information
jdkanani committed Feb 17, 2020
2 parents b343bd1 + 04f5abc commit 67260a7
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
18 changes: 18 additions & 0 deletions consensus/bor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,21 @@ func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error) {
}
return snap.signers(), nil
}

// GetCurrentProposer gets the current proposer
func (api *API) GetCurrentProposer() (common.Address, error) {
snap, err := api.GetSnapshot(nil)
if err != nil {
return common.Address{}, err
}
return snap.ValidatorSet.GetProposer().Address, nil
}

// GetCurrentValidators gets the current validators
func (api *API) GetCurrentValidators() ([]*Validator, error) {
snap, err := api.GetSnapshot(nil)
if err != nil {
return make([]*Validator, 0), err
}
return snap.ValidatorSet.Validators, nil
}
45 changes: 43 additions & 2 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var Modules = map[string]string{
"admin": AdminJs,
"chequebook": ChequebookJs,
"clique": CliqueJs,
"bor": BorJs,
"ethash": EthashJs,
"debug": DebugJs,
"eth": EthJs,
Expand Down Expand Up @@ -112,6 +113,46 @@ web3._extend({
});
`

const BorJs = `
web3._extend({
property: 'bor',
methods: [
new web3._extend.Method({
name: 'getSnapshot',
call: 'bor_getSnapshot',
params: 1,
inputFormatter: [null]
}),
new web3._extend.Method({
name: 'getSnapshotAtHash',
call: 'bor_getSnapshotAtHash',
params: 1
}),
new web3._extend.Method({
name: 'getSigners',
call: 'bor_getSigners',
params: 1,
inputFormatter: [null]
}),
new web3._extend.Method({
name: 'getSignersAtHash',
call: 'bor_getSignersAtHash',
params: 1
}),
new web3._extend.Method({
name: 'getCurrentProposer',
call: 'bor_getCurrentProposer',
params: 0
}),
new web3._extend.Method({
name: 'getCurrentValidators',
call: 'bor_getCurrentValidators',
params: 0
}),
]
});
`

const EthashJs = `
web3._extend({
property: 'ethash',
Expand Down Expand Up @@ -765,15 +806,15 @@ web3._extend({
const LESJs = `
web3._extend({
property: 'les',
methods:
methods:
[
new web3._extend.Method({
name: 'getCheckpoint',
call: 'les_getCheckpoint',
params: 1
}),
],
properties:
properties:
[
new web3._extend.Property({
name: 'latestCheckpoint',
Expand Down

0 comments on commit 67260a7

Please sign in to comment.