MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / UpdatePermission

Function UpdatePermission

client/driver.go:355–405  ·  view source on GitHub ↗

UpdatePermission sends UpdatePermission transaction to chain.

(targetUser proto.AccountAddress,
	targetChain proto.AccountAddress, perm *types.UserPermission)

Source from the content-addressed store, hash-verified

353
354// UpdatePermission sends UpdatePermission transaction to chain.
355func UpdatePermission(targetUser proto.AccountAddress,
356 targetChain proto.AccountAddress, perm *types.UserPermission) (txHash hash.Hash, err error) {
357 if atomic.LoadUint32(&driverInitialized) == 0 {
358 err = ErrNotInitialized
359 return
360 }
361
362 var (
363 pubKey *asymmetric.PublicKey
364 privKey *asymmetric.PrivateKey
365 addr proto.AccountAddress
366 nonce interfaces.AccountNonce
367 )
368 if pubKey, err = kms.GetLocalPublicKey(); err != nil {
369 return
370 }
371 if privKey, err = kms.GetLocalPrivateKey(); err != nil {
372 return
373 }
374 if addr, err = crypto.PubKeyHash(pubKey); err != nil {
375 return
376 }
377
378 nonce, err = getNonce(addr)
379 if err != nil {
380 return
381 }
382
383 up := types.NewUpdatePermission(&types.UpdatePermissionHeader{
384 TargetSQLChain: targetChain,
385 TargetUser: targetUser,
386 Permission: perm,
387 Nonce: nonce,
388 })
389 err = up.Sign(privKey)
390 if err != nil {
391 log.WithError(err).Warning("sign failed")
392 return
393 }
394 addTxReq := new(types.AddTxReq)
395 addTxResp := new(types.AddTxResp)
396 addTxReq.Tx = up
397 err = requestBP(route.MCCAddTx, addTxReq, addTxResp)
398 if err != nil {
399 log.WithError(err).Warning("send tx failed")
400 return
401 }
402
403 txHash = up.Hash()
404 return
405}
406
407// TransferToken send Transfer transaction to chain.
408func TransferToken(targetUser proto.AccountAddress, amount uint64, tokenType types.TokenType) (

Callers 2

runGrantFunction · 0.92
TestUpdatePermissionFunction · 0.70

Calls 10

SignMethod · 0.95
GetLocalPublicKeyFunction · 0.92
GetLocalPrivateKeyFunction · 0.92
PubKeyHashFunction · 0.92
NewUpdatePermissionFunction · 0.92
WithErrorFunction · 0.92
getNonceFunction · 0.85
requestBPFunction · 0.85
WarningMethod · 0.80
HashMethod · 0.65

Tested by 1

TestUpdatePermissionFunction · 0.56