ts bindings: Failure when converting function return value
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, rust, typescript
- Domain
- api, developer-experience
Research direction
Start at soroban-client/lib/contract_spec.js around line 374 and inspect how the generated binding converts an Option<(u32, u32)> return value. Reproduce the JavaScript call to coords with token_id 0 and compare it with the CLI result [17,31]. Done means the TypeScript binding converts this return value without throwing.
Written by the indexing model from the issue text.
Description
What version are you using?
soroban --version
soroban 20.0.0-rc4 (bce5e56ba16ba977200b022c91f3eaf6282f47eb)
soroban-env 20.0.0-rc2 (8c63bff68a15d79aca3a705ee6916a68db57b7e6)
soroban-env interface version 85899345977
stellar-xdr 20.0.0-rc1 (d5ce0c9e7aa83461773a6e81662067f35d39e4c1)
xdr curr (9ac02641139e6717924fdad716f6e958d0168491)
Rust
soroban-sdk = { version = "20.0.0-rc2", default-features = false }
What did you do?
I'm using the generated typescript binding and for a function returning an Option<(u32, u32)> throws an error when, it seems, the value is converted to native.
error Type [object Object] was not vec, but [object Object] is
File:
.../millionlumenhomepage/mlh-frontend/node_modules/Million/node_modules/soroban-client/lib/contract_spec.js:374:19
Code:
373 | }
> 374 | throw new TypeError("Type ".concat(typeDef, " was not vec, but ").concat(scv, " is"));
| ^
375 | }
376 | case _stellarBase.xdr.ScValType.scvAddress().value:
377 | return _stellarBase.Address.fromScVal(scv);
The soroban function is like this:
pub fn coords(env: Env, token_id: u32) -> Option<(u32, u32)> {
Coords::Xy(token_id).get(&env)?
}
And the javascript call that throws the error:
let xy = await million.coords({token_id: parseInt(id)})
Calling the contract with the cli gives:
soroban contract invoke --id $(cat contract.id) --source user1 --network standalone -- coords --token_id 0
[17,31]
- Dominant language
- Rust
- Stars
- 123
- Forks
- 141
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 17
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stellar/stellar-cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stellar/stellar-cli#2384 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stellar/stellar-cli#2347 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
stellar/stellar-cli#2723 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
stellar/stellar-cli#2722 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
stellar/stellar-cli#2703 ·
All issues in stellar/stellar-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100