Merge pull request #19 from maticnetwork/dev-span-sprint-api-calls

Dev span sprint api calls
This commit is contained in:
Jaynti Kanani 2020-02-17 19:52:32 +05:30 committed by GitHub
commit 67260a717e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 2 deletions

View file

@ -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
}

View file

@ -22,6 +22,7 @@ var Modules = map[string]string{
"admin": AdminJs,
"chequebook": ChequebookJs,
"clique": CliqueJs,
"bor": BorJs,
"ethash": EthashJs,
"debug": DebugJs,
"eth": EthJs,
@ -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',
@ -765,7 +806,7 @@ web3._extend({
const LESJs = `
web3._extend({
property: 'les',
methods:
methods:
[
new web3._extend.Method({
name: 'getCheckpoint',
@ -773,7 +814,7 @@ web3._extend({
params: 1
}),
],
properties:
properties:
[
new web3._extend.Property({
name: 'latestCheckpoint',