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

Inaccurate Value generated in offchain code datum #93

Open
arressaye opened this issue Jul 28, 2023 · 1 comment
Open

Inaccurate Value generated in offchain code datum #93

arressaye opened this issue Jul 28, 2023 · 1 comment

Comments

@arressaye
Copy link

I have datum defined in my contract as such

struct Datum {
    sender: PubKeyHash
    recipient: PubKeyHash
    exchange_for: Value
}

When I generate the datum in offchain code like so:

const heliosDatum = new EscrowProgram.types.Datum(
    helios.hexToBytes(helios.Address.fromBech32(sender).pubKeyHash.hex),
    helios.hexToBytes(helios.Address.fromBech32(recipient).pubKeyHash.hex),
    helios.Value.fromCbor(helios.hexToBytes(recipientValue))
  );

Note that recipientValue above is a CBOR hex string of a Value created from Cardano Serialization Library and not a Helios Value therefore it had to be converted.

The resulting Value of the datum contains only the non-ADA assets even though the recipientValue is the CBOR hex string of the full value I'm interested in, including ADA. Indeed if I run console.log(helios.Value.fromCbor(helios.hexToBytes(recipientValue)).lovelace.toString()); I do get the full value including ADA and native tokens printed to console. The ADA portion just doesn't get included in the datum somehow.

I've tested a few different scenarios and it seems like if recipientValue contained only ADA or only native tokens, the Datum will be correct. However if it included both ADA and native tokens, the Value in the Datum will ignore the ADA portion.

@christianschmitz
Copy link
Contributor

I'm unable to replicate this using just the _toUplcData() method, so that part seems to be correct.

Do you have a more complete case with which I can replicate this?

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

2 participants