Skip to content

User Report -> not able to unwrap bNEO  #2383

@picarodias

Description

@picarodias

User report:

@tyler Users encounters a bug when using NEON. When users want to unwrap bNEO the contract requires that the data argument is null. When we try to send an invocation script with data=null NEON shows an error message. Example of invoke script:

[
    {
        "scriptHash": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
        "operation": "transfer",
        "args": [
            {
                "type": "Address",
                "value": "NNsCaRsqr2UigVoLCQ7GVvsDRzeDTWgj4x"
            },
            {
                "type": "Address",
                "value": "NPmdLGJN47EddqYcxixdGMhtkr7Z5w4Aos"
            },
            {
                "type": "Integer",
                "value": "100000"
            },
            {
                "type": "Any",
                "value": null
            }
        ]
    }
]

When we force the data field to be an empty string, NEON succeeds, but the the transaction silently fails on-chain, and user never receives the NEO:
https://dora.coz.io/transaction/neo3/mainnet/0x0916973b7100961022ce30b9bfe7d094a52a463d82a31b3a8090f152520ad993

I have talked with WangLongLang about this, and he is not gonna change the bNEO contract to accept an empty string, so this will have to be fixed on NEON side. How fast will you guys be able to fix so that NEON accepts "Any: null"?

A lot of features of the system is tied to automatic wrapping/unwrapping of bNEO and all users using NEO will now see errors when trying to use these functions.

Tech Report on Neon-JS side

_by @ixje _

I did some analysis of the above not understanding what they mean with "unwrap bNEO".

  1. the transaction linked does not silently fail it actually succeeds as can be seen from requesting the applicationlog (VMState == HALT and notifications have been sent).
  2. the transaction linked calls onNEP17Payment() on the BurgerNEO contract with the arguments 0x405e4ebaad618d82a35eb87c292eae15c24e6220, 100000, 00 (the last value is a ByteString stack item). They probably want the last item to be null such that they pass this statement: https://github.com/neoburger/code/blob/2902285cd35cd4a44cec4aef27b8251cf13e18ca/BurgerNEO.cs#L59

I don't know how they're creating the call, but this is the right way to build the script

import { CONST, sc } from "@cityofzion/neon-core";

const script = sc.createScript({
  scriptHash: CONST.NATIVE_CONTRACT_HASH.GasToken,
  operation: "transfer",
  args: [
    sc.ContractParam.hash160("NNsCaRsqr2UigVoLCQ7GVvsDRzeDTWgj4x"),
    sc.ContractParam.hash160("NPmdLGJN47EddqYcxixdGMhtkr7Z5w4Aos"),
    100000,
    sc.ContractParam.any(),
  ],
});

It's a near copy/paste from the documentation. I actually verified this code by forcing transaction 0x0916973b7100961022ce30b9bfe7d094a52a463d82a31b3a8090f152520ad993 to use my fixed script instead and verifying that the data argument is indeed null.In conclusion; neon-js is fine.

Metadata

Metadata

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions