additional APIs

This commit is contained in:
vsmk98 2018-11-07 13:58:51 +08:00
parent 3c68a587ba
commit b28fa8b445
2 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package quorum
import (
"fmt"
"math/big"
"strconv"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
@ -37,6 +38,7 @@ const (
ApproveNodeBlacklisting
AddVoter
RemoveVoter
SetAccountAccess
)
// OrgKeyAction represents an action in cluster contract
@ -64,6 +66,8 @@ type txArgs struct {
orgId string
keyId string
txa ethapi.SendTxArgs
acctId common.Address
accessType string
}
// NewPermissionAPI creates a new PermissionAPI to access quorum services
@ -146,6 +150,10 @@ func (s *PermissionAPI) AddOrgKey(orgId string, pvtKey string, txa ethapi.SendTx
return s.executeOrgKeyAction(AddOrgKey, txArgs{txa: txa, orgId: orgId, keyId: pvtKey})
}
func (s *PermissionAPI) SetAccountAccess(acct common.Address, access string, txa ethapi.SendTxArgs) bool {
return s.executePermAction(SetAccountAccess, txArgs{acctId: acct, accessType: access, txa: txa})
}
// executePermAction helps to execute an action in permission contract
func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) bool {
w, err := s.validateAccount(args.txa.From)
@ -253,6 +261,13 @@ func (s *PermissionAPI) executePermAction(action PermAction, args txArgs) bool {
}
enodeID := node.ID.String()
tx, err = ps.BlacklistNode(enodeID)
case SetAccountAccess:
access, err := strconv.ParseUint(args.accessType, 10, 8)
if err != nil {
return false
}
log.Info("SMK-SetAccountAccess @ 269", "acctId", args.acctId, "access", uint8(access))
tx, err = ps.UpdateAccountAccess(args.acctId, uint8(access))
}
if err != nil {

View File

@ -742,6 +742,12 @@ web3._extend({
call: 'quorum_approveNodeBlacklisting',
params: 2,
inputFormatter: [null,web3._extend.formatters.inputTransactionFormatter]
}),
new web3._extend.Method({
name: 'setAccountAccess',
call: 'quorum_setAccountAccess',
params: 3,
inputFormatter: [web3._extend.formatters.inputAddressFormatter,null,web3._extend.formatters.inputTransactionFormatter]
}),
new web3._extend.Method({
name: 'addOrgKey',