CityOfZion / neon-js

Javascript libraries that allow the applications to interact with NEO blockchain
https://docs.coz.io/neo3/neon-js/index.html
MIT License
183 stars 165 forks source link

WitnessRule deserialize failed #872

Closed xie-yue closed 1 year ago

xie-yue commented 1 year ago

v5.2.0 neo3 neon-core/lib/tx/components/WitnessRule

serialize() { return (this.action.toString(16).padStart(2, "0") + this.condition.serialize()); }

static deserialize(ss) { const action = parseEnum(ss.read(1), WitnessRuleAction); ... }

in deserialize, the first param ss.read(1) will be 01 (Allow) witch was not defined in WitnessRuleAction. throw an error 01 not found in enum!

xie-yue commented 1 year ago

seems like missed parseInt, result of ss.read(1) is a string

ixje commented 1 year ago

I'll have a look a.s.a.p

ixje commented 1 year ago

Expect a PR later in the day (European timezone) fixing this and some other issue I encountered

ixje commented 1 year ago

@xie-yue see the PR :point_up: Note: a new release might not happen until after the weekend. Waiting for the maintainer approval on the PR

EdgeDLT commented 1 year ago

I think I may be having some related errors when it comes to tx serialization. I did a little bit of light testing. With tx.serialize() and only the validUntilBlock property set, I get the expected hexstring. A few others serialize fine too, like fees.

Trying with only signers added gave:

prop.map((p) => (typeof p === "string" ? p : p.serialize())).join(""));
                                                       ^      
TypeError: p.serialize is not a function

Trying with only script added gave:

throw new Error(`num2hexstring expected a number but got ${typeof num} instead.`);
              ^

Error: num2hexstring expected a number but got undefined instead.

Opened as new issue #875.

ixje commented 1 year ago

@xie-yue fyi; https://www.npmjs.com/package/@cityofzion/neon-js/v/5.2.1

xie-yue commented 1 year ago

worked perfectly! thx!