diff --git a/rosetta/services/construction_check.go b/rosetta/services/construction_check.go index 53d1b5f2a..e38eb6a36 100644 --- a/rosetta/services/construction_check.go +++ b/rosetta/services/construction_check.go @@ -240,16 +240,17 @@ func (s *ConstructAPI) ConstructionMetadata( evmErrorMsg := "" evmReturn := hexutil.Bytes{} - if !isStakingOperation(options.OperationType) && - options.OperationType != common.ContractCreationOperation && - len(data) > 0 { + if len(data) > 0 && (options.OperationType == common.ContractCreationOperation || + options.OperationType == common.NativeTransferOperation) { gas := hexutil.Uint64(estGasUsed) callArgs := rpc.CallArgs{ From: senderAddr, - To: &contractAddress, Data: &data, Gas: &gas, } + if options.OperationType == common.NativeTransferOperation { + callArgs.To = &contractAddress + } evmExe, err := rpc.DoEVMCall( ctx, s.hmy, callArgs, ethRpc.LatestBlockNumber, vm.Config{}, rpc.CallTimeout, s.hmy.RPCGasCap, ) diff --git a/rosetta/services/tx_operation.go b/rosetta/services/tx_operation.go index 682e6645c..8d7f4a28b 100644 --- a/rosetta/services/tx_operation.go +++ b/rosetta/services/tx_operation.go @@ -158,20 +158,16 @@ func getAmountFromDelegateMessage(receipt *hmytypes.Receipt, data []byte) (*type }) } - stkAmount := stkMsg.Amount + deductedAmt := stkMsg.Amount logs := hmytypes.FindLogsWithTopic(receipt, staking.DelegateTopic) for _, log := range logs { - if len(log.Data) > ethcommon.AddressLength { - validatorAddress := ethcommon.BytesToAddress(log.Data[:ethcommon.AddressLength]) - if log.Address == stkMsg.DelegatorAddress && stkMsg.ValidatorAddress == validatorAddress { - // Remove re-delegation amount as funds were never credited to account's balance. - stkAmount = new(big.Int).Sub(stkAmount, new(big.Int).SetBytes(log.Data[ethcommon.AddressLength:])) - break - } + if len(log.Data) > ethcommon.AddressLength && log.Address == stkMsg.DelegatorAddress { + // Remove re-delegation amount as funds were never credited to account's balance. + deductedAmt = new(big.Int).Sub(deductedAmt, new(big.Int).SetBytes(log.Data[ethcommon.AddressLength:])) } } return &types.Amount{ - Value: negativeBigValue(stkAmount), + Value: negativeBigValue(deductedAmt), Currency: &common.NativeCurrency, }, nil }