-
Notifications
You must be signed in to change notification settings - Fork 47
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
JS: Constant SC_SPEC_DOC_LIMIT doesn't get replaced with a JavaScript XDR constant #152
Comments
Also, the same issue appears with
Where I get the JavaScript generated without xdr.union("ScObject", {
switchOn: xdr.lookup("ScObjectType"),
switchName: "type",
switches: [
["scoVec", "vec"],
["scoMap", "map"],
["scoU64", "u64"],
["scoI64", "i64"],
["scoU128", "u128"],
["scoI128", "i128"],
["scoBytes", "bin"],
["scoContractCode", "contractCode"],
["scoAddress", "address"],
["scoNonceKey", "nonceAddress"],
],
arms: {
vec: xdr.lookup("ScVec"),
map: xdr.lookup("ScMap"),
u64: xdr.lookup("Uint64"),
i64: xdr.lookup("Int64"),
u128: xdr.lookup("Int128Parts"),
i128: xdr.lookup("Int128Parts"),
bin: xdr.varOpaque(SCVAL_LIMIT),
contractCode: xdr.lookup("ScContractCode"),
address: xdr.lookup("ScAddress"),
nonceAddress: xdr.lookup("ScAddress"),
},
}); This line in particular. bin: xdr.varOpaque(SCVAL_LIMIT), Here's another example. struct ContractCodeEntry {
ExtensionPoint ext;
Hash hash;
opaque code<SCVAL_LIMIT>;
}; I get no xdr.struct("ContractCodeEntry", [
["ext", xdr.lookup("ExtensionPoint")],
["hash", xdr.lookup("Hash")],
["code", xdr.varOpaque(SCVAL_LIMIT)],
]); |
@paulbellamy Did you encounter any issues with constants when generating the code for js-stellar-base? We've had the SCVAL_LIMIT constant in the XDR for months at this point, and it looks like we generated the code just fine in https://github.com/stellar/js-stellar-base/blob/master/src/generated/next_generated.js. |
@wildework Are you asking that every location should use lookup, or should not use lookup? I just want to confirm that because the issue description says the lookup shouldn't be there, but the following comment with examples sounds like the lookup should be there. |
@leighmcculloch most instances of xdr.varOpaque(SCVAL_LIMIT) As a constant |
@leighmcculloch And sorry about the mix-up, I flipped the order for "expect" and "did see". I have fixed my original post with the correct order now. And just to be explicit - we need to use |
@wildework What are the direct consequences for you of this bug? Trying to understand the impact and therefore the urgency. |
@ire-and-curses For me, it's a matter of manually editing the generated JS code. I've already solved this downstream in my sdk https://github.com/useSoroban/sdk/blob/trunk/source/xdr.js#L748 so this bug only affects people that will be using the official Stellar JavaScript SDK and trying to parse data of types that rely on |
not quite, @leighmcculloch: https://github.com/stellar/js-stellar-base/blob/f508a02f239df9810a35e3704d2081dbdf05a3c9/src/generated/next_generated.js#L7931-L7952 It seems to fail in the case of unions and structs that use the constant to define an array's size, e.g. |
Basically, there are no downstream risks because we have to fix this manually anyway to release new versions of (Note that this wasn't done for |
Posting to keep this alive. I pulled the latest version of The same with |
Yep, unfortunately we're still doing the manual workaround as this bug hasn't been a priority: https://github.com/stellar/js-stellar-base/blob/72887306042382f8faffd78bd3e3bd1e9155dab4/src/generated/next_generated.js#L10-L15. Maybe after Soroban on pubnet! |
It's cool that |
What version are you using?
I'm using the
6e42b01e1ceb25c251d4c4d45443d7e0f228822a
commit version.What did you do?
From the root folder of the repository, I call
xdrgen
../bin/xdrgen -o ../stellar_sdk/xdr -l javascript -n stellar ../stellar-xdr/*.x
Every instance of
SC_SPEC_DOC_LIMIT
is not replaced with a constant lookup, here's one example.What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: