js-stellar-sdk
js-stellar-sdk copied to clipboard
XDR parse error for Option<Vec<Object>>
Describe the bug Option is not getting properly parsed when it is for a vector of objects
What version are you on? 12.3.0
To Reproduce
Steps to reproduce the behavior:
I added a type to other_custom_types wasm for a test case: https://github.com/stellar/soroban-examples/pull/326
With that wasm you can add this to the custom types e2e tests:
it("get_object_vec_option", async function () {
const expectedResult = [
{ a: 1, b: true, c: "hi" },
{ a: 2, b: false, c: "hello" }
];
const result = await this.context.client.get_object_vec_option();
expect(result.result).to.deep.equal(expectedResult);
});
Expected behavior It should return the vector of objects (or null if the option is null)
Additional context
TypeError: Type [object Object] was not vec, but [object Object] is
at Spec.scValToNative (lib/contract/spec.js:848:19)
at Spec.funcResToNative (lib/contract/spec.js:529:19)
at Object.parseResultXdr (lib/contract/client.js:59:25)
at AssembledTransaction.result (lib/contract/assembled_transaction.js:433:29)
at Context.<anonymous> (test/e2e/src/test-custom-types.js:291:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Looks like this is coming from this line in spec.ts, so assigning this to @willemneal as the author :saluting_face:
Fixed #1228