Preprocess endpoint thinks Operation.Type is not valid

Hi there, I’m implementing the /construction/preprocess endpoint right now. However when I submit a request, it says the Operation.Type isn’t valid even though it’s listed in /network/options.

Here is the request:

{
    "network_identifier": {
        "blockchain": "Helium",
        "network": "Mainnet"
    },
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "debit_op",
            "status": "SUCCESS",
            "account": {
                "address": "13HPSdf8Ng8E2uKpLm8Ba3sQ6wdNimTcaKXYmMkHyTUUeUELPwJ"
            },
            "amount": {
                "value": "-2995000000",
                "currency": {
                    "symbol": "HNT",
                    "decimals": 8
                }
            },
            "metadata": {
                "credit_category": "payment"
            }
        }
    ],
    "metadata": {}
}

Which outputs this:

{
    "code": 0,
    "message": "Operation.Type is invalid: debit_op: operation type is invalid in operation 0",
    "retriable": false
}

Here is /network/options output:

{
    "version": {
        "rosetta_version": "1.4.10",
        "node_version": "1.1.23"
    },
    "allow": {
        "operation_statuses": [
            {
                "status": "SUCCESS",
                "successful": true
            },
            {
                "status": "FAILURE",
                "successful": false
            }
        ],
        "operation_types": [
            "credit_op",
            "debit_op",
            "fee_op",
            "add_gateway_op",
            "assert_location_op"
        ],
        "errors": [
            {
                "code": 0,
                "message": "Endpoint not implemented",
                "retriable": false
            },
            {
                "code": 1,
                "message": "Object not found",
                "retriable": false
            },
            {
                "code": 2,
                "message": "Endpoint failed",
                "retriable": false
            },
            {
                "code": 3,
                "message": "Invalid parameter",
                "retriable": false
            },
            {
                "code": 4,
                "message": "InvalidPassword",
                "retriable": false
            },
            {
                "code": 5,
                "message": "Unable to derive address",
                "retriable": false
            },
            {
                "code": 6,
                "message": "Unable to parse intent",
                "retriable": false
            },
            {
                "code": 7,
                "message": "Unable to parse intermediate result",
                "retriable": false
            },
            {
                "code": 11,
                "message": "Unable to parse transaction into valid operations",
                "retriable": false
            },
            {
                "code": 8,
                "message": "Unable to decode address",
                "retriable": false
            },
            {
                "code": 9,
                "message": "Signature invalid",
                "retriable": false
            },
            {
                "code": 10,
                "message": "Environment variable missing",
                "retriable": false
            }
        ],
        "historical_balance_lookup": false,
        "call_methods": null,
        "balance_exemptions": null,
        "mempool_coins": false
    }
}

debit_op is clearly the second item in the list for allowed operation_types so not sure what the problem is here.

Sorry I resolved my own problem. I had initiated the server incorrectly. Instead of passing valid operation types into the NewServer function in main.go, I had passed an array of higher level transaction types instead.

a, err := asserter.NewServer(
	helium.OperationTypes,                    // <-- Originally helium.TransactionTypes
	helium.HistoricalBalanceSupported,
	[]*types.NetworkIdentifier{network},
	nil,
	false,
)
if err != nil {
	log.Fatal(err)
}

Glad you figured out the root cause @suyan100! :slight_smile: