did

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 14 Imported by: 0

README

DID module

Note

The passphrase is used in the DID module is not sended to the chain.

Usage

(Tx) Create DID
// Set info to create DID
createDIDMsg := types.CreateDIDMsg{
    DIDMnemonic:    "catalog appear keep human ...",
    DIDPassphrase:  "passphrase",
    SaveDIDKeyPath: "/DID/KEY/DIRECTORY",
    // moniker is option
    Moniker:        "didMoniker",
}

txbytes, err := xplac.CreateDID(createDIDMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Update DID
// Update exist DID 
updateDIDMSg := types.UpdateDIDMsg{
    DID:             "did:xpla:mM54wt4G3KBJaJSXEfFv87BuxRHQ2K9WS3m7crFReCL",
    KeyID:           "key1",
    DIDPassphrase:   "passphrase",
    DIDKeyPath:      "DID/KEY/DIRECTORY",
    DIDDocumentPath: "NEW/DID/DOC/DIRECTORY",
}

txbytes, err := xplac.UpdateDID(updateDIDMSg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Deactivate DID
// Deactivate exist DID
deactivateDIDMsg := types.DeactivateDIDMsg{
    DID:           "did:xpla:mM54wt4G3KBJaJSXEfFv87BuxRHQ2K9WS3m7crFReCL",
    KeyID:         "key1",
    DIDPassphrase: "passphrase",
    DIDKeyPath:    "DID/KEY/DIRECTORY",
}

txbytes, err := xplac.DeactivateDID(deactivateDIDMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Replace DID Moniker
// Replace DID moniker
replaceDIDMonikerMsg := types.ReplaceDIDMonikerMsg{
    DID:           "did:xpla:mM54wt4G3KBJaJSXEfFv87BuxRHQ2K9WS3m7crFReCL",
    KeyId:         "key1",
    DIDPassphrase: "passphrase",
    DIDKeyPath:    "DID/KEY/DIRECTORY",
    NewMoniker:    "newDidMoniker",
}

txbytes, err := xplac.ReplaceDIDMoniker(replaceDIDMonikerMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Query) Get DID info
// Get DID info
getDIDMsg := types.GetDIDMsg{
    DID: "did:xpla:mM54wt4G3KBJaJSXEfFv87BuxRHQ2K9WS3m7crFReCL",
}

res, err := xplac.GetDID(getDIDMsg).Query()
(Query) Moniker by DID
// Get moniker by DID
monikerByDIDMsg := types.MonikerByDIDMsg{
    DID: "did:xpla:mM54wt4G3KBJaJSXEfFv87BuxRHQ2K9WS3m7crFReCL",
}

res, err := xplac.MonikerByDID(monikerByDIDMsg).Query()
(Query) DID by moniker
// Get DID by moniker
didByMonikerMsg := types.DIDByMonikerMsg{
    Moniker: "didMoniker",
}

res, err := xplac.DIDByMoniker(didByMonikerMsg).Query()
(Query) Get All DIDs
// Get all DIDs are activated
res, err := xplac.AllDIDs().Query()

Documentation

Index

Constants

View Source
const (
	DidModule                   = "did"
	DidCreateDidMsgType         = "create-did"
	DidUpdateDidMsgType         = "update-did"
	DidDeactivateDidMsgType     = "deactivate-did"
	DidReplaceDidMonikerMsgType = "replace-did-moniker"
	DidGetDidMsgType            = "get-did"
	DidMonikerByDidMsgType      = "moniker-by-did"
	DidDidByMonikerMsgType      = "did-by-moniker"
	DidAllDidsMsgType           = "all-dids"
)

Variables

This section is empty.

Functions

func MakeAllDIDsMsg added in v0.0.2

func MakeAllDIDsMsg() (didtypes.QueryAllDIDsRequest, error)

(Query) - all dids

func MakeCreateDIDMsg

func MakeCreateDIDMsg(createDIDMsg types.CreateDIDMsg, privKey key.PrivateKey) (didtypes.MsgCreateDID, error)

(Tx) make msg - create DID

func MakeDIDByMonikerMsg added in v0.0.2

func MakeDIDByMonikerMsg(didByMonikerMsg types.DIDByMonikerMsg) (didtypes.QueryDIDByMonikerRequest, error)

(Query) - did by moniker

func MakeDeactivateDIDMsg

func MakeDeactivateDIDMsg(deactivateDIDMsg types.DeactivateDIDMsg, lcdUrl, grpcUrl string, grpcConn grpc.ClientConn, privKey key.PrivateKey, ctx context.Context) (didtypes.MsgDeactivateDID, error)

(Tx) make msg - deactivate DID

func MakeGetDIDMsg

func MakeGetDIDMsg(getDIDMsg types.GetDIDMsg) (didtypes.QueryDIDRequest, error)

(Query) - get DID

func MakeMonikerByDIDMsg added in v0.0.2

func MakeMonikerByDIDMsg(monikerByDIDMsg types.MonikerByDIDMsg) (didtypes.QueryMonikerByDIDRequest, error)

(Query) - moniker by DID

func MakeReplaceDIDMonikerMsg added in v0.0.2

func MakeReplaceDIDMonikerMsg(replaceDIDMonikerMsg types.ReplaceDIDMonikerMsg, lcdUrl, grpcUrl string, grpcConn grpc.ClientConn, privKey key.PrivateKey, ctx context.Context) (didtypes.MsgReplaceDIDMoniker, error)

(Tx) make msg - replace DID moniker

func MakeUpdateDIDMsg

func MakeUpdateDIDMsg(updateDIDMsg types.UpdateDIDMsg, lcdUrl, grpcUrl string, grpcConn grpc.ClientConn, privKey key.PrivateKey, ctx context.Context) (didtypes.MsgUpdateDID, error)

(Tx) make msg - update DID

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL