From 83c12ced533ebcd1b6bdff3663221c2440816c86 Mon Sep 17 00:00:00 2001 From: sidhujag Date: Tue, 8 Sep 2020 08:35:06 -0700 Subject: [PATCH] token type in tx outside of TTS --- api/types.go | 1 + api/worker.go | 9 +++------ bchain/types.go | 1 - static/templates/txdetail.html | 1 + 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api/types.go b/api/types.go index f792de87..a4cdceb5 100644 --- a/api/types.go +++ b/api/types.go @@ -152,6 +152,7 @@ type Tx struct { CoinSpecificData interface{} `json:"-"` CoinSpecificJSON json.RawMessage `json:"-"` TokenTransferSummary []*bchain.TokenTransferSummary `json:"tokenTransfers,omitempty"` + TokenType string `json:"tokenType,omitempty"` EthereumSpecific *EthereumSpecific `json:"ethereumSpecific,omitempty"` } diff --git a/api/worker.go b/api/worker.go index 0ae4d206..1623de4c 100644 --- a/api/worker.go +++ b/api/worker.go @@ -224,7 +224,6 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe } assetGuid := strconv.FormatUint(uint64(vin.AssetInfo.AssetGuid), 10) tts = &bchain.TokenTransferSummary{ - Type: txVersionAsset, Token: assetGuid, Decimals: int(dbAsset.AssetObj.Precision), Value: (*bchain.Amount)(big.NewInt(0)), @@ -270,7 +269,6 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe } assetGuid := strconv.FormatUint(uint64(vout.AssetInfo.AssetGuid), 10) tts = &bchain.TokenTransferSummary{ - Type: txVersionAsset, Token: assetGuid, Decimals: int(dbAsset.AssetObj.Precision), Value: (*bchain.Amount)(big.NewInt(0)), @@ -368,6 +366,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe CoinSpecificData: bchainTx.CoinSpecificData, CoinSpecificJSON: sj, TokenTransferSummary: tokens, + TokenType: txVersionAsset, EthereumSpecific: ethSpecific, } return r, nil @@ -420,7 +419,6 @@ func (w *Worker) GetTransactionFromMempoolTx(mempoolTx *bchain.MempoolTx) (*Tx, } assetGuid := strconv.FormatUint(uint64(vin.AssetInfo.AssetGuid), 10) tts = &bchain.TokenTransferSummary{ - Type: txVersionAsset, Token: assetGuid, Decimals: int(dbAsset.AssetObj.Precision), Value: (*bchain.Amount)(big.NewInt(0)), @@ -470,7 +468,6 @@ func (w *Worker) GetTransactionFromMempoolTx(mempoolTx *bchain.MempoolTx) (*Tx, } assetGuid := strconv.FormatUint(uint64(vout.AssetInfo.AssetGuid), 10) tts = &bchain.TokenTransferSummary{ - Type: txVersionAsset, Token: assetGuid, Decimals: int(dbAsset.AssetObj.Precision), Value: (*bchain.Amount)(big.NewInt(0)), @@ -526,6 +523,7 @@ func (w *Worker) GetTransactionFromMempoolTx(mempoolTx *bchain.MempoolTx) (*Tx, Vin: vins, Vout: vouts, TokenTransferSummary: tokens, + TokenType: txVersionAsset, EthereumSpecific: ethSpecific, } return r, nil @@ -734,7 +732,6 @@ func (w *Worker) txFromTxAddress(txid string, ta *bchain.TxAddresses, bi *bchain } assetGuid := strconv.FormatUint(uint64(vin.AssetInfo.AssetGuid), 10) tts = &bchain.TokenTransferSummary{ - Type: txVersionAsset, Token: assetGuid, Decimals: int(dbAsset.AssetObj.Precision), Value: (*bchain.Amount)(big.NewInt(0)), @@ -773,7 +770,6 @@ func (w *Worker) txFromTxAddress(txid string, ta *bchain.TxAddresses, bi *bchain } assetGuid := strconv.FormatUint(uint64(vout.AssetInfo.AssetGuid), 10) tts = &bchain.TokenTransferSummary{ - Type: txVersionAsset, Token: assetGuid, Decimals: int(dbAsset.AssetObj.Precision), Value: (*bchain.Amount)(big.NewInt(0)), @@ -811,6 +807,7 @@ func (w *Worker) txFromTxAddress(txid string, ta *bchain.TxAddresses, bi *bchain Vin: vins, Vout: vouts, TokenTransferSummary: tokens, + TokenType: txVersionAsset, } return r } diff --git a/bchain/types.go b/bchain/types.go index 2156a204..ad691ec4 100644 --- a/bchain/types.go +++ b/bchain/types.go @@ -564,7 +564,6 @@ func (t Tokens) Less(i, j int) bool { // TokenTransferSummary contains info about a token transfer done in a transaction type TokenTransferSummary struct { - Type TokenType `json:"type"` From string `json:"from"` To string `json:"to"` Token string `json:"token"` diff --git a/static/templates/txdetail.html b/static/templates/txdetail.html index 8cbe9612..d46ddcb8 100644 --- a/static/templates/txdetail.html +++ b/static/templates/txdetail.html @@ -4,6 +4,7 @@
{{$tx.Txid}} {{- if $tx.Rbf}} ⚠️{{end -}} + {{- if $tx.TokenType != "SPTUnknown"}}($tx.TokenType){{end -}}
{{- if $tx.Blocktime}}
{{if $tx.Confirmations}}mined{{else}}first seen{{end}} {{formatUnixTime $tx.Blocktime}}
{{end -}}