Code Monkey home page Code Monkey logo

Comments (13)

MartinSchere avatar MartinSchere commented on August 15, 2024 2

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;
  }

from nami.

alessandrokonrad avatar alessandrokonrad commented on August 15, 2024 1

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.

from nami.

alessandrokonrad avatar alessandrokonrad commented on August 15, 2024 1

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

from nami.

MartinSchere avatar MartinSchere commented on August 15, 2024

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'.

from nami.

MartinSchere avatar MartinSchere commented on August 15, 2024

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

from nami.

MartinSchere avatar MartinSchere commented on August 15, 2024

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?

from nami.

alessandrokonrad avatar alessandrokonrad commented on August 15, 2024

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

from nami.

MartinSchere avatar MartinSchere commented on August 15, 2024

What is the bool thing about?

from nami.

MartinSchere avatar MartinSchere commented on August 15, 2024

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

from nami.

alessandrokonrad avatar alessandrokonrad commented on August 15, 2024

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.

from nami.

alessandrokonrad avatar alessandrokonrad commented on August 15, 2024

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

from nami.

ElGatoLoco avatar ElGatoLoco commented on August 15, 2024

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?

from nami.

MartinSchere avatar MartinSchere commented on August 15, 2024

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

from nami.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.