From 1105270df76c72597f422bdc8dff0b830e2cf1e4 Mon Sep 17 00:00:00 2001 From: Jingfu Wang Date: Wed, 8 Feb 2023 16:57:43 -0500 Subject: [PATCH] fix: mint ops (#21) Signed-off-by: Jingfu Wang --- pkg/handlers/mint.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/handlers/mint.go b/pkg/handlers/mint.go index 0809ec4..5f8b992 100644 --- a/pkg/handlers/mint.go +++ b/pkg/handlers/mint.go @@ -4,7 +4,6 @@ import ( evmClient "github.com/coinbase/rosetta-geth-sdk/client" sdkTypes "github.com/coinbase/rosetta-geth-sdk/types" RosettaTypes "github.com/coinbase/rosetta-sdk-go/types" - log "github.com/ethereum/go-ethereum/log" common "github.com/mdehoog/op-rosetta/pkg/common" ) @@ -13,18 +12,24 @@ func MintOps(tx *evmClient.LoadedTransaction, startIndex int) []*RosettaTypes.Op if tx.Transaction.Mint() == nil { return nil } - log.Info("mint operation detected", "tx", tx.TxHash) + + opIndex := int64(startIndex) + opType := common.MintOpType + opStatus := sdkTypes.SuccessStatus + toAddress := evmClient.MustChecksum(tx.Transaction.To().String()) + amount := evmClient.Amount(tx.Transaction.Mint(), sdkTypes.Currency) + return []*RosettaTypes.Operation{ { OperationIdentifier: &RosettaTypes.OperationIdentifier{ - Index: int64(startIndex), + Index: opIndex, }, - Type: common.MintOpType, - Status: RosettaTypes.String(sdkTypes.SuccessStatus), + Type: opType, + Status: RosettaTypes.String(opStatus), Account: &RosettaTypes.AccountIdentifier{ - Address: tx.From.String(), + Address: toAddress, }, - Amount: evmClient.Amount(tx.Transaction.Mint(), sdkTypes.Currency), + Amount: amount, }, } }