Error decoding contract event deployed with forc 0.63.5, fuel-core 0.35.0

The ABI changes here do not reference the the data coming back from this transaction.

Once I changed you’re ABI back to the old the data structure:

    {
      "type": "struct events::DepositEvent",
      "metadataTypeId": 27,
      "components": [
        {
          "name": "amount",
          "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
        },
        {
          "name": "asset",
          "typeId": 35
        },
        {
          "name": "user",
          "typeId": 16
        },
        {
          "name": "liquid_base",
          "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
        },
        {
          "name": "liquid_quote",
          "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
        }
      ]
    },

I could successfully decode the event:

[
  {
    "amount": 10000000,
    "asset": {
      "bits": "0x336b7c06352a4b736ff6f688ba6885788b3df16e136e95310ade51aa32dc6f05"
    },
    "user": {
      "Address": {
        "bits": "0x1ef4ca23f77ddd39400e32199f1e7e4a85dff2067a850ee0944ed6ece25c30fe"
      }
    },
    "liquid_base": 0,
    "liquid_quote": 10000000
  },
  96
]

Please could you check that you’ve redeployed your contract and the transaction event you’re trying to decode matches the new data structure!

@p.s struct balance:
-liquid.base
-liqud.quote
-locked.base
-locked.quote

if i do a second deposit event for btc for example, i should get this

DepositEvent {
  amount: 777,
  asset: 0x38e4ca985b22625fff93205e997bfc5cc8453a953da638ad297ca60a9f2600bc,
  user: 0x1ef4ca23f77ddd39400e32199f1e7e4a85dff2067a850ee0944ed6ece25c30fe
  ),
  balance: Account {
    liquid: Balance {
      base: 777,
      quote: 10000000
    },
    locked: Balance {
      base: 0,
      quote: 0
    }
  }
}

like the third event

OpenOrderEvent {
  amount: 777,
  asset: 0x38e4ca985b22625fff93205e997bfc5cc8453a953da638ad297ca60a9f2600bc,
  user: 0x1ef4ca23f77ddd39400e32199f1e7e4a85dff2067a850ee0944ed6ece25c30fe
  ),
  balance: Account {
    liquid: Balance {
      base: 0,
      quote: 10000000
    },
    locked: Balance {
      base: 777,
      quote: 0
    }
  }
}

so the balance is the user’s state after each event.
With the old abi we could only get liquid balances, but we needed to have access to locked balances, so we added struct balance to the event.

we could do this

pub struct DepositEvent {
    pub amount: u64,
    pub asset: AssetId,
    pub user: Identity,
    pub liquid_base: u64,
    pub liquid_quote: u64,
    pub locked_base: u64,
    pub locked_base: u64
}

instead of

pub struct DepositEvent {
    pub amount: u64,
    pub asset: AssetId,
    pub user: Identity,
    pub balance: Account,
}

but it’s not good for gas

The encoded length for this new structure you have provided below is 112.

This structure does no conform to the the data provided in your initial message (encoded length being 96):

0x0000000000989680336b7c06352a4b736ff6f688ba6885788b3df16e136e95310ade51aa32dc6f0500000000000000001ef4ca23f77ddd39400e32199f1e7e4a85dff2067a850ee0944ed6ece25c30fe00000000000000000000000000989680

Please redeploy with the new contract (and structure) and create a new transaction and this should work as expected!

Have you got a new transaction ID and logged data for this one?

@p.s no, i cant do nothing if deposit fails, its just example

yes,because the old abi doesn’t have locked balances

    pub locked_base: u64,
    pub locked_base: u64

Please could you supply a new DepositEvent transaction, with the new contract (w/ expected results) here.

These issues are our priority!

@p.s hi! i redeployed new contract (0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54)

indexer fails with the same problem

[11:46:43.612] ERROR (63958): error decoding event
    chainId: 0
    logType: "Block Range Query"
    workerType: "HyperFuel"
    fromBlock: 0
    toBlock: 11194552
    addresses: [
      "0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54"
    ]
    fetchStateRegister: "root"
    blockNumber: 11194282
    logIndex: 1
    responsible event: {
      "blockHeight": 11194282,
      "blockTimestamp": 1727167327,
      "contractId": "0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54",
      "receipt": {
        "blockHeight": 11194282,
        "data": "0x0000000000000064336b7c06352a4b736ff6f688ba6885788b3df16e136e95310ade51aa32dc6f0500000000000000001ef4ca23f77ddd39400e32199f1e7e4a85dff2067a850ee0944ed6ece25c30fe00000000000000000000000000000064",
        "ra": 0,
        "rb": 12590297951544648000,
        "receiptIndex": 1,
        "receiptType": 6,
        "rootContractId": "0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54",
        "txId": "0xe0444456b1becec5da47aee439ac1dd5cdf1380cc82f116cd36941aeb63cff91",
        "txStatus": 0
      },
      "receiptIndex": 1,
      "receiptType": 6,
      "transactionId": "0xe0444456b1becec5da47aee439ac1dd5cdf1380cc82f116cd36941aeb63cff91"
    }

[11:46:43.621] ERROR (63958): Failed to parse event with Fuel, please double check your ABI.
    chainId: 0
    logType: "Block Range Query"
    workerType: "HyperFuel"
    fromBlock: 0
    toBlock: 11194552
    addresses: [
      "0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54"
    ]
    fetchStateRegister: "root"
    blockNumber: 11194282
    logIndex: 1
    err: {
      "type": "_FuelError",
      "message": "Invalid u64 byte data size.",
      "stack":
          FuelError: Invalid u64 byte data size.
              at BigNumberCoder.decode (/Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:453:13)
              at /Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:955:41
              at Array.reduce (<anonymous>)
              at _c.decode (/Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:952:51)
              at /Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:955:41
              at Array.reduce (<anonymous>)
              at _c.decode (/Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:952:51)
              at /Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:955:41
              at Array.reduce (<anonymous>)
              at _c.decode (/Users/master/spark-envio-indexer/generated/src/bindings/vendored-fuel-abi-coder.js:952:51)
      "VERSIONS": {
        "FORC": "0.63.5",
        "FUEL_CORE": "0.35.0",
        "FUELS": "0.94.6"
      },
      "metadata": {},
      "rawError": null,
      "code": "decode-error",
      "name": "FuelError"
    }
./target/release/spark-cli core deposit \                                                                (1) (*event-updates-0.4.0+330) 10:53:52 
                                  --asset-type quote \
                                  --amount 100 \
                                  --rpc "testnet.fuel.network" \
                                  --contract-id 0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54
Spark CLI v0.4.0

Contract call cost: 3688
Deposited 100 amount of asset 100
^^/orderbook-contract >>> ./target/release/spark-cli info account \                                                                    (*event-updates-0.4.0+330) 11:50:16 
                                  --account-type address \
                                  --account-id 0x1ef4ca23f77ddd39400e32199f1e7e4a85dff2067a850ee0944ed6ece25c30fe \
                                  --rpc "testnet.fuel.network" \
                                  --contract-id 0xc24ecaddd54cb04b88fb657da41da54e805aa2789654101dac7ede7716923e54
Spark CLI v0.4.0

Contract base asset balance: 342185172

Account {
    liquid: Balance {
        base: 0,
        quote: 100,
    },
    locked: Balance {
        base: 0,
        quote: 0,
    },
}

Hey :wave:

I’m taking a look into this now.

@PaulZhemanov Please could you link me the contract ABI (commit) that produced this error?

@p.s orderbook-contract/spark-market/out/release/spark-market-abi.json at event-updates-0.4.0 · compolabs/orderbook-contract · GitHub