diff --git a/consensus/posv/posv.go b/consensus/posv/posv.go index fd6fee1e2e..4a163fb09e 100644 --- a/consensus/posv/posv.go +++ b/consensus/posv/posv.go @@ -819,7 +819,12 @@ func CalcDifficulty(snap *Snapshot, signer common.Address) *big.Int { // APIs implements consensus.Engine, returning the user facing RPC API to allow // controlling the signer voting. func (c *Posv) APIs(chain consensus.ChainReader) []rpc.API { - return []rpc.API{} + return []rpc.API{{ + Namespace: "posv", + Version: "1.0", + Service: &API{chain: chain, posv: c}, + Public: false, + }} } func (c *Posv) RecoverSigner(header *types.Header) (common.Address, error) { diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 9d6ce8c6c8..6efca4e9aa 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -21,6 +21,7 @@ var Modules = map[string]string{ "admin": Admin_JS, "chequebook": Chequebook_JS, "clique": Clique_JS, + "posv": Posv_JS, "debug": Debug_JS, "eth": Eth_JS, "miner": Miner_JS, @@ -109,6 +110,43 @@ web3._extend({ }); ` +const Posv_JS = ` +web3._extend({ + property: 'posv', + methods: [ + new web3._extend.Method({ + name: 'getSnapshot', + call: 'posv_getSnapshot', + params: 1, + inputFormatter: [null] + }), + new web3._extend.Method({ + name: 'getSnapshotAtHash', + call: 'posv_getSnapshotAtHash', + params: 1 + }), + new web3._extend.Method({ + name: 'getSigners', + call: 'posv_getSigners', + params: 1, + inputFormatter: [null] + }), + new web3._extend.Method({ + name: 'getSignersAtHash', + call: 'posv_getSignersAtHash', + params: 1 + }), + ], + properties: [ + new web3._extend.Property({ + name: 'proposals', + getter: 'posv_proposals' + }), + ] +}); +` + + const Admin_JS = ` web3._extend({ property: 'admin',