Repository: trustwallet/blockatlas
Pull request #948 (2020-03-01 09:03:39)

Rename StatusFailed to StatusError


Patch:
diff --git a/pkg/blockatlas/tx.go b/pkg/blockatlas/tx.go
index 6e40b64..7ae77f4 100644
--- a/pkg/blockatlas/tx.go
+++ b/pkg/blockatlas/tx.go
@@ -11,7 +11,7 @@ type KeyTitle string
 const (
 	StatusCompleted Status = "completed"
 	StatusPending   Status = "pending"
-	StatusFailed    Status = "failed"
+	StatusError     Status = "error"
 
 	DirectionOutgoing Direction = "outgoing"
 	DirectionIncoming Direction = "incoming"
diff --git a/platform/cosmos/transaction.go b/platform/cosmos/transaction.go
index 3051e7c..5a08c1f 100644
--- a/platform/cosmos/transaction.go
+++ b/platform/cosmos/transaction.go
@@ -96,7 +96,7 @@ func (p *Platform) Normalize(srcTx *Tx) (tx blockatlas.Tx, ok bool) {
 	status := blockatlas.StatusCompleted
 	// https://github.com/cosmos/cosmos-sdk/blob/95ddc242ad024ca78a359a13122dade6f14fd676/types/errors/errors.go#L19
 	if srcTx.Code > 0 {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	}
 
 	tx = blockatlas.Tx{
diff --git a/platform/ethereum/transaction.go b/platform/ethereum/transaction.go
index 882fa83..e3dfbd0 100644
--- a/platform/ethereum/transaction.go
+++ b/platform/ethereum/transaction.go
@@ -49,7 +49,7 @@ func extractBase(srcTx *Doc, coinIndex uint) (base blockatlas.Tx, ok bool) {
 	if srcTx.Error == "" {
 		status = blockatlas.StatusCompleted
 	} else {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 		errReason = srcTx.Error
 	}
 
diff --git a/platform/nebulas/transaction.go b/platform/nebulas/transaction.go
index d31df4d..c22ce5a 100644
--- a/platform/nebulas/transaction.go
+++ b/platform/nebulas/transaction.go
@@ -41,7 +41,7 @@ func NormalizeTxs(txs []Transaction) []blockatlas.Tx {
 func NormalizeTx(srcTx Transaction) blockatlas.Tx {
 	var status = blockatlas.StatusCompleted
 	if srcTx.Status == 0 {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	}
 	return blockatlas.Tx{
 		ID:       srcTx.Hash,
diff --git a/platform/ontology/transaction.go b/platform/ontology/transaction.go
index c2fb048..5721640 100644
--- a/platform/ontology/transaction.go
+++ b/platform/ontology/transaction.go
@@ -34,7 +34,7 @@ func Normalize(srcTx *Tx, assetName AssetType) (tx blockatlas.Tx, ok bool) {
 	fee := numbers.DecimalExp(srcTx.Fee, ONGDecimals)
 	status := blockatlas.StatusCompleted
 	if srcTx.ConfirmFlag != 1 {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	}
 	tx = blockatlas.Tx{
 		ID:     srcTx.Hash,
diff --git a/platform/polkadot/transaction.go b/platform/polkadot/transaction.go
index 1685c71..5a1387c 100644
--- a/platform/polkadot/transaction.go
+++ b/platform/polkadot/transaction.go
@@ -35,7 +35,7 @@ func (p *Platform) NormalizeTransfer(srcTx *Transfer) blockatlas.Tx {
 	amount := strings.Split(numbers.DecimalExp(srcTx.Amount, int(decimals)), ".")[0]
 	status := blockatlas.StatusCompleted
 	if !srcTx.Success {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	}
 	result := blockatlas.Tx{
 		ID:     srcTx.Hash,
@@ -75,7 +75,7 @@ func (p *Platform) NormalizeExtrinsic(srcTx *Extrinsic) *blockatlas.Tx {
 
 	var status blockatlas.Status
 	if !srcTx.Success {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	} else {
 		status = blockatlas.StatusCompleted
 	}
diff --git a/platform/ripple/transaction.go b/platform/ripple/transaction.go
index 84f0fd8..68e054a 100644
--- a/platform/ripple/transaction.go
+++ b/platform/ripple/transaction.go
@@ -55,7 +55,7 @@ func NormalizeTx(srcTx *Tx) (blockatlas.Tx, bool) {
 
 	status := blockatlas.StatusCompleted
 	if srcTx.Meta.TransactionResult != transactionResultSuccess {
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	}
 
 	result := blockatlas.Tx{
diff --git a/platform/tezos/transaction.go b/platform/tezos/transaction.go
index 354c795..d2615e4 100644
--- a/platform/tezos/transaction.go
+++ b/platform/tezos/transaction.go
@@ -49,7 +49,7 @@ func NormalizeTx(srcTx Transaction) (blockatlas.Tx, bool) {
 	status := blockatlas.StatusCompleted
 	if srcTx.Status() != TxStatusApplied {
 		errMsg = "transaction failed"
-		status = blockatlas.StatusFailed
+		status = blockatlas.StatusError
 	}
 	tx := blockatlas.Tx{
 		ID:     srcTx.Op.OpHash,
diff --git a/platform/zilliqa/transaction.go b/platform/zilliqa/transaction.go
index cb52d1e..c18bda5 100644
--- a/platform/zilliqa/transaction.go
+++ b/platform/zilliqa/transaction.go
@@ -41,7 +41,7 @@ func Normalize(srcTx *Tx) (tx blockatlas.Tx) {
 		},
 	}
 	if !srcTx.ReceiptSuccess {
-		tx.Status = blockatlas.StatusFailed
+		tx.Status = blockatlas.StatusError
 	}
 	return tx
 }


Test patch:
diff --git a/platform/cosmos/transaction_test.go b/platform/cosmos/transaction_test.go
index c571ec9..32570c7 100644
--- a/platform/cosmos/transaction_test.go
+++ b/platform/cosmos/transaction_test.go
@@ -664,7 +664,7 @@ var failedTransferDst = blockatlas.Tx{
 	Fee:    "2000",
 	Date:   1576120902,
 	Block:  5552,
-	Status: blockatlas.StatusFailed,
+	Status: blockatlas.StatusError,
 	Type:   blockatlas.TxTransfer,
 	Memo:   "UniCoins registration rewards",
 	Meta: blockatlas.Transfer{
diff --git a/platform/ethereum/transaction_test.go b/platform/ethereum/transaction_test.go
index c26a50f..eef7313 100644
--- a/platform/ethereum/transaction_test.go
+++ b/platform/ethereum/transaction_test.go
@@ -172,7 +172,7 @@ var failedDst = blockatlas.Tx{
 	Date:     1554662399,
 	Block:    7522678,
 	Sequence: 1,
-	Status:   blockatlas.StatusFailed,
+	Status:   blockatlas.StatusError,
 	Error:    "Error",
 	Meta: blockatlas.Transfer{
 		Value:    "59859820000000000",
diff --git a/platform/ripple/transaction_test.go b/platform/ripple/transaction_test.go
index ef640be..8cbc06a 100644
--- a/platform/ripple/transaction_test.go
+++ b/platform/ripple/transaction_test.go
@@ -199,7 +199,7 @@ var failedPaymentDst = blockatlas.Tx{
 	Date:   1581590872,
 	Block:  53401154,
 	Memo:   "",
-	Status: blockatlas.StatusFailed,
+	Status: blockatlas.StatusError,
 	Meta: blockatlas.Transfer{
 		Value:    "24999750000",
 		Symbol:   "XRP",
diff --git a/platform/tezos/transaction_test.go b/platform/tezos/transaction_test.go
index 125acb9..42e56ca 100644
--- a/platform/tezos/transaction_test.go
+++ b/platform/tezos/transaction_test.go
@@ -274,7 +274,7 @@ var transfer3 = blockatlas.Tx{
 		Symbol:   coin.Coins[coin.XTZ].Symbol,
 		Decimals: coin.Coins[coin.XTZ].Decimals,
 	},
-	Status: blockatlas.StatusFailed,
+	Status: blockatlas.StatusError,
 	Error:  "transaction failed",
 }