From aad957e2a36169feae28618eb3ccd48198ba7ce6 Mon Sep 17 00:00:00 2001 From: scorpiotzh <835598264@qq.com> Date: Wed, 12 Jun 2024 14:01:47 +0800 Subject: [PATCH] feat: update lib --- block_parser/action_did_cell.go | 63 +++++---------------------------- go.mod | 2 +- go.sum | 4 +-- 3 files changed, 11 insertions(+), 58 deletions(-) diff --git a/block_parser/action_did_cell.go b/block_parser/action_did_cell.go index 7d7b0f5..f8ad93f 100644 --- a/block_parser/action_did_cell.go +++ b/block_parser/action_did_cell.go @@ -24,27 +24,12 @@ func (b *BlockParser) ActionEditDidCellRecords(req *FuncTransactionHandleReq) (r return } - //var didCellData witness.DidCellData - //if err := didCellData.BysToObj(req.Tx.OutputsData[txDidEntity.Outputs[0].Target.Index]); err != nil { - // resp.Err = fmt.Errorf("didCellData.BysToObj err: %s", err.Error()) - // return - //} - sporeData, didCellData, err := witness.BysToDidCellData(req.Tx.OutputsData[txDidEntity.Outputs[0].Target.Index]) + account, _, err := witness.GetAccountAndExpireFromDidCellData(req.Tx.OutputsData[txDidEntity.Outputs[0].Target.Index]) if err != nil { - resp.Err = fmt.Errorf("witness.BysToDidCellData err: %s", err.Error()) + resp.Err = fmt.Errorf("witness.GetAccountAndExpireFromDidCellData err: %s", err.Error()) return } - account := "" - if sporeData != nil { - didCellDataLV, err := sporeData.ContentToDidCellDataLV() - if err != nil { - resp.Err = fmt.Errorf("sporeData.ContentToDidCellDataLV err: %s", err.Error()) - return - } - account = didCellDataLV.Account - } else if didCellData != nil { - account = didCellData.Account - } + accountId := common.Bytes2Hex(common.GetAccountIdByAccount(account)) var recordsInfos []tables.TableRecordsInfo recordList := txDidEntity.Outputs[0].DidCellWitnessDataV0.Records @@ -87,27 +72,12 @@ func (b *BlockParser) ActionEditDidCellOwner(req *FuncTransactionHandleReq) (res resp.Err = fmt.Errorf("TxToOneDidEntity err: %s", err.Error()) return } - //var didCellData witness.DidCellData - //if err := didCellData.BysToObj(req.Tx.OutputsData[didEntity.Target.Index]); err != nil { - // resp.Err = fmt.Errorf("didCellData.BysToObj err: %s", err.Error()) - // return - //} - sporeData, didCellData, err := witness.BysToDidCellData(req.Tx.OutputsData[didEntity.Target.Index]) + + account, _, err := witness.GetAccountAndExpireFromDidCellData(req.Tx.OutputsData[didEntity.Target.Index]) if err != nil { - resp.Err = fmt.Errorf("witness.BysToDidCellData err: %s", err.Error()) + resp.Err = fmt.Errorf("witness.GetAccountAndExpireFromDidCellData err: %s", err.Error()) return } - account := "" - if sporeData != nil { - didCellDataLV, err := sporeData.ContentToDidCellDataLV() - if err != nil { - resp.Err = fmt.Errorf("sporeData.ContentToDidCellDataLV err: %s", err.Error()) - return - } - account = didCellDataLV.Account - } else if didCellData != nil { - account = didCellData.Account - } didCellArgs := common.Bytes2Hex(req.Tx.Outputs[didEntity.Target.Index].Lock.Args) accountId := common.Bytes2Hex(common.GetAccountIdByAccount(account)) @@ -149,28 +119,11 @@ func (b *BlockParser) ActionDidCellRecycle(req *FuncTransactionHandleReq) (resp log.Info("ActionDidCellRecycle:", req.BlockNumber, req.TxHash, req.Action) preTxDidEntity, err := witness.TxToOneDidEntity(preTx.Transaction, witness.SourceTypeOutputs) - //var preDidCellData witness.DidCellData - //if err := preDidCellData.BysToObj(preTx.Transaction.OutputsData[preTxDidEntity.Target.Index]); err != nil { - // resp.Err = fmt.Errorf("didCellData.BysToObj err: %s", err.Error()) - // return - //} - - sporeData, didCellData, err := witness.BysToDidCellData(preTx.Transaction.OutputsData[preTxDidEntity.Target.Index]) + account, _, err := witness.GetAccountAndExpireFromDidCellData(preTx.Transaction.OutputsData[preTxDidEntity.Target.Index]) if err != nil { - resp.Err = fmt.Errorf("witness.BysToDidCellData err: %s", err.Error()) + resp.Err = fmt.Errorf("witness.GetAccountAndExpireFromDidCellData err: %s", err.Error()) return } - account := "" - if sporeData != nil { - didCellDataLV, err := sporeData.ContentToDidCellDataLV() - if err != nil { - resp.Err = fmt.Errorf("sporeData.ContentToDidCellDataLV err: %s", err.Error()) - return - } - account = didCellDataLV.Account - } else if didCellData != nil { - account = didCellData.Account - } accountId := common.Bytes2Hex(common.GetAccountIdByAccount(account)) oldOutpoint := common.OutPointStruct2String(req.Tx.Inputs[0].PreviousOutput) diff --git a/go.mod b/go.mod index 05f8ac0..c6a1c20 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module das-account-indexer go 1.18 require ( - github.com/dotbitHQ/das-lib v1.1.1-0.20240606090840-e9f3a432c836 + github.com/dotbitHQ/das-lib v1.1.1-0.20240612034840-4b0c2da94d04 github.com/fsnotify/fsnotify v1.5.4 github.com/gin-gonic/gin v1.9.1 github.com/go-redis/redis v6.15.9+incompatible diff --git a/go.sum b/go.sum index 2d69f30..b6ea78c 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5O github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= -github.com/dotbitHQ/das-lib v1.1.1-0.20240606090840-e9f3a432c836 h1:/FEJmc1RM88ke4ttxHsBZHix714+0iaCDTih3tKuBn8= -github.com/dotbitHQ/das-lib v1.1.1-0.20240606090840-e9f3a432c836/go.mod h1:XrDous4HH3jze59GLdmdKZaAQ8h3unTFUBsppph7IF8= +github.com/dotbitHQ/das-lib v1.1.1-0.20240612034840-4b0c2da94d04 h1:UH8qKDMZ6RMKYipkNpzWtUjz6rjL+SgPJfgmUH4RNOs= +github.com/dotbitHQ/das-lib v1.1.1-0.20240612034840-4b0c2da94d04/go.mod h1:XrDous4HH3jze59GLdmdKZaAQ8h3unTFUBsppph7IF8= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0=