Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inputs do not conform to this spec or are otherwise invalid #71

Closed
MartinSchere opened this issue Oct 2, 2021 · 13 comments
Closed

Inputs do not conform to this spec or are otherwise invalid #71

MartinSchere opened this issue Oct 2, 2021 · 13 comments

Comments

@MartinSchere
Copy link

I'm getting this error when trying to sign the simplest transaction:

cardano-cli transaction build-raw \
    --tx-in 88d9225ff5d46b0efcd56dda20f2ea93b0a5fa232e7f70ab7d626746075a20d1#0 \
    --tx-out addr_test1qzymym7qc47kx65sjhntdl2prq85rj5v8mzv5pvyffnntz4el5zqnamef3yt2kprt866p5f38w6um6642lvzrj80d0xstnnmxq+10 \
    --tx-out addr_test1qzjlc05tyyw264wy7m4u7np5yqdwglks0xhu6765cl4qex9r9kvav4hmznru9px9n7cpa2hmmv4593eegve3t834xppqwskp4t+999823269 \
    --invalid-hereafter 369400 \
    --fee 176721 \
    --out-file tx.raw

ready2

It's an alonzo-era transaction

@MartinSchere
Copy link
Author

When doing the following:

const cborHex =
      "83a4008182582088d9225ff5d46b0efcd56dda20f2ea93b0a5fa232e7f70ab7d626746075a20d10001828258390089b26fc0c57d636a9095e6b6fd41180f41ca8c3ec4ca05844a67358ab9fd0409f7794c48b5582359f5a0d1313bb5cdeb5557d821c8ef6bcd0a82583900a5fc3e8b211cad55c4f6ebcf4c34201ae47ed079afcd7b54c7ea0c98a32d99d656fb14c7c284c59fb01eaafbdb2b42c7394333159e3530421a3b9817a5021a0002b251031a0005a2f89ffff6";

    const rawTx = CardanoWasm.Transaction.from_bytes(
      Buffer.from(cborHex, "hex")
    );

It gives the error:

Uncaught (in promise) Deserialization failed in Transaction.witness_set.TransactionWitnessSet because: Invalid cbor: not the right type, expected Map' byte received Array'.

@alessandrokonrad
Copy link
Contributor

The raw transaction coming from the cardano-cli does not follow the ledger specs actually. That's why Nami is complaining or better said the serialization-lib. You need to transform the cbor code a little bit. Get rid of the empty arrays at the top and replace them with a map and remove the bool in case there is one.

@MartinSchere
Copy link
Author

OK, so it's possible to build an alonzo-era transaction and sign it with Nami?

I'm looking for a way to enable smart contracts in my dApp without waiting for the PAB release

@alessandrokonrad
Copy link
Contributor

Yes it's possible. I'll release a new Nami version soon, that also handles the additional bool in the transaction from the cardano-cli

@MartinSchere
Copy link
Author

Yes, given that the PAB will be here in a few weeks, should the link handler be implemented in Nami? Or the dApp connector is made with the serialization lib?

@alessandrokonrad
Copy link
Contributor

alessandrokonrad commented Oct 6, 2021

Yeah Nami is fully built on top of the serialization-lib. I currently use a customized version of the serialization-lib, which follows the latest specs: https://github.com/input-output-hk/cardano-ledger-specs/blob/master/eras/alonzo/test-suite/cddl-files/alonzo.cddl
The bool thing is not in the latest official release yet. The new Nami version should come these days. It's version 2.0.0
It also exposes a new endpoint called getCollateral

@MartinSchere
Copy link
Author

What is the bool thing about?

@MartinSchere
Copy link
Author

Oh, and where can I contact you about SpaceBudz? I tried to reach you on Discord, but you must have your dms off.

@alessandrokonrad
Copy link
Contributor

What is the bool thing about?

I think it's an extra flag that tells if the contract evaluates to true or false. I don't know exactly the purpose of it.

@alessandrokonrad
Copy link
Contributor

Oh, and where can I contact you about SpaceBudz? I tried to reach you on Discord, but you must have your dms off.

Yeah I'm trying to avoid some platforms atm. You can reach me on telegram @berry_ales

@MartinSchere
Copy link
Author

I created a toSpec helper function and it worked:

  public toSpec(txFilePath: string): string {
    const file = JSON.parse(readFileSync(txFilePath, 'utf-8'));

    const { cborHex } = file;
    const decoded = cbor.decode(cborHex);
    const newCborDecoded = [];

    for (let i of decoded) {
      if (Array.isArray(i)) {
        newCborDecoded.push(new Map());
      } else if (typeof i !== 'boolean') {
        newCborDecoded.push(i);
      }
    }
    const result = cbor.encode(newCborDecoded).toString('hex');
    return result;
  }

@ElGatoLoco
Copy link

I created a toSpec helper function and it worked:

  public toSpec(txFilePath: string): string {
    const file = JSON.parse(readFileSync(txFilePath, 'utf-8'));

    const { cborHex } = file;
    const decoded = cbor.decode(cborHex);
    const newCborDecoded = [];

    for (let i of decoded) {
      if (Array.isArray(i)) {
        newCborDecoded.push(new Map());
      } else if (typeof i !== 'boolean') {
        newCborDecoded.push(i);
      }
    }
    const result = cbor.encode(newCborDecoded).toString('hex');
    return result;
  }

This is all good until you actually have some data in those arrays that needs to be transformed. Did you by any chance come up with a way to transform arrays to maps properly?

@MartinSchere
Copy link
Author

No, I migrated to the serialization lib because the interaction was easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants