-
Notifications
You must be signed in to change notification settings - Fork 82
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
[TypeError]: XDR Write Error: [object Object] is not a ScVal #1285
Comments
Full unminified error ✘ [ERROR] a [TypeError]: XDR Write Error: [object Object] is not a ScVal
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/union.js:85:13)
at ve.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/var-array.js:43:23)
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/struct.js:31:12)
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/union.js:88:21)
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/struct.js:31:12)
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/union.js:88:21)
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/struct.js:31:12)
at ve.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/var-array.js:43:23)
at p.write
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/struct.js:31:12)
at p.toXDR
(file:///Users/tylervanderhoeven/Desktop/Web/Colorglyph-2.0/colorglyph-viewer/node_modules/@stellar/js-xdr/dist/webpack:/XDR/src/xdr-type.js:57:10) |
My best guess is there's a mix between using or bundling a client side / browser version of something with a server / node version of something and that toggle is correct some or even most of the time but in the Cloudflare edge environment it isn't and thus there's some type mismatch. |
I will say it's really strange to me that the |
I've been looking into this bug as well. I'm pretty new to the Stellar ecosystem but I figured I'd post my current findings in case someone with more familiarity with the xdr library might have some insight. I found that simply putting the Hello World sample contract It works fine when the hello method is put in the front matter of the Astro page, ie when its run server side. When run client side, the error occurs due to the |
Bug Reproduction Steps
mkdir xdr-write-error && cd xdr-write-error
<script>
import helloWorld from "../contracts/hello_world";
const { result } = await helloWorld.hello({ to: "you" });
console.log(result);
</script>
npm run dev
|
Could be a sdk bug... |
@Shaptic We are quite blocked on this. Would you be able to take a look in this or pair with @BlaineHeffron on this? Thanks in advance :) |
There's likely a stellar-base somewhere that there shouldn't be, or an SDK version mismatch. Can you please give it another go with v12.0.0-rc2 to see if the issue persists? |
Just tried here: Colorglyph/colorglyph-viewer@ad6ecab |
The astro template has outdated dependencies which might be causing this, but I can't find a similar issue in colorglyph 😕 I wonder if, for some reason, exporting the SDK as part of the generated client somehow creates a copy that conflicts with the built-ins.... or if this is another instance of this bug and that bridge needs to be crossed now. |
Updated the astro site with all the latest stuff You have to spin up a local docker network before running
|
I'm also using the latest CLI version right from the |
Another instance of this bug stellar/js-soroban-client#124 |
@chadoh did we confirm this was fixed in the 12rc2? My tests indicated it did not |
Probably an auto-close via GitHub, I'll reopen |
I think GitHub did that because I have this in the description:
|
me github, me |
I've opened stellar/js-xdr#122 as an attempt to patch this due to its urgency and our (my) inability to root cause this quickly, please give it a look! |
@Shaptic It still fails the new check. |
Some more info, the JSON stringify value of what fails is The prototype is as follows for server build:
The client version (webpack build) prototype
Note that These are from my notes so they aren't from your PR on js-xdr. |
I also checked the logic around line 150 of |
Great notes, thank you 🙏 I think if we can figure out where the heck |
Here is the json stringify and prototype with the new js-xdr code:
|
I printed out the prototypes in var-array, union, and struct and everything is identical to the server build up until that scvSymbol. This is very odd, in the old build I could trace the symbol back to it being a child of Enum. But in this case the $ is stumping me. So I added some debug text in the Enum class, and it seems to be called 'k' in this build. So either I was mistaken before and it wasn't a child of Enum or something in some changes caused its inheritance to change... |
What version are you using?
https://github.com/stellar/js-stellar-sdk/tree/cf-worker
(this is a fork of
master
with a customaxios
adapter to work with Cloudflare Workers)What did you do?
Tried to use the TS bindings to call a contract method.
What did you expect to see?
Success.
What did you see instead?
[TypeError]: XDR Write Error: [object Object] is not a ScVal
Extra info
Here's a simple repo showcasing the error
https://github.com/Colorglyph/colorglyph-viewer
The text was updated successfully, but these errors were encountered: