Skip to content

Commit

Permalink
fixed resolved did bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbin committed Sep 23, 2024
1 parent 05ab476 commit 54ac6db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 10 additions & 6 deletions internal/didapi/didtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ type RpcTranasactionData struct {
}

func (rpcTxData *RpcTranasactionData) FromTranasactionData(txData did.DIDTransactionData) bool {
hash, err := elacom.Uint256FromHexString(txData.TXID)
txid := txData.TXID
if txid[0:2] == "0x" {
txid = txid[2:]
}
hash, err := elacom.Uint256FromHexString(txid)
if err != nil {
return false
}
Expand Down Expand Up @@ -91,19 +95,19 @@ func (rpcTxData *RpcTranasactionData) ToResolveTxData() ResolveTranasactionData

// resolve payload of DID transaction
type ResolvePayloadDIDInfo struct {
DID string `json:"did"`
Status int `json:"status"`
DID string `json:"did"`
Status int `json:"status"`
RpcTXDatas []ResolveTranasactionData `json:"transaction,omitempty"`
}

type ResolveTranasactionData struct {
TXID string `json:"txid"`
Timestamp string `json:"timestamp"`
TXID string `json:"txid"`
Timestamp string `json:"timestamp"`
Operation ResolveOperation `json:"operation"`
}

type ResolveOperation struct {
Header did.Header `json:"header"`
Payload did.DIDDoc `json:"payload"`
Proof did.Proof `json:"proof"`
}
}
5 changes: 4 additions & 1 deletion internal/ethapi/didapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,13 @@ func (s *PublicTransactionPoolAPI) ResolveDID(ctx context.Context, param map[str
rpcPayloadDid.DID = txData.Operation.DIDDoc.ID
err, timestamp := s.getTxTime(ctx, txData.TXID)
if err != nil {
log.Error("getTxTime failed ", "error", err)
continue
}
tempTXData := new(didapi.RpcTranasactionData)
succe := tempTXData.FromTranasactionData(txData)
if succe == false {
if !succe {
log.Error("FromTranasactionData error >>>> ")
continue
}

Expand All @@ -495,6 +497,7 @@ func (s *PublicTransactionPoolAPI) ResolveDID(ctx context.Context, param map[str
//fill in
deactiveTXData, err := s.getDeactiveTx(ctx, buf.Bytes())
if err != nil {
log.Error("getDeactiveTx failed >>>> ", " error ", err)
return nil, err
}
rpcPayloadDid.RpcTXDatas = append(rpcPayloadDid.RpcTXDatas, *deactiveTXData)
Expand Down

0 comments on commit 54ac6db

Please sign in to comment.