-
Notifications
You must be signed in to change notification settings - Fork 137
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
Add abstractions for converting ScVal
s to native types.
#628
Comments
What's the win with |
@leighmcculloch please refer to #620: it allows easy conversion between I suppose having it go to |
That's fine too, however to your point in the doc that linked to this issue, there's so much confusion created by the exposure of non-native types like xdr types, so anything we can do to make them fade away rather than use them or types like them for conversions will probably improve the developer experience. At least to the extent we can do so without compromising on capability. |
Yep, you make a good point! |
One thing to note. Scvmap could be a rust struct, which would be better represented as a js object (TS interface). I had initially gone with As for the bytes I vote |
I moved away from Can you expand a bit on the API and input/output you might like to see, so I can get a better sense of what you're looking for? |
It would be similar to the CLI: The tricky part is figuring out the corresponding the ScTypeDef. This could be done by the bindings code. For example adding it here: |
I'm marking this as closed by #630 for tracking purposes, but opening a new issue for the remaining work! |
Is your feature request related to a problem? Please describe.
Given an arbitrary
ScVal
type, converting it into a form natively usable from your chosen language is difficult and error prone.Describe the solution you'd like
Easy conversion methods from
ScVal
s to native types.Here is the list of types and conversations:
scvBool
➡️boolean
scvVoid
➡️null
scvU32
➡️number
scvI32
➡️number
scvU64
➡️bigint
scvI64
➡️bigint
scvTimepoint
➡️bigint
scvDuration
➡️bigint
scvU128
➡️bigint
scvI128
➡️bigint
scvU256
➡️bigint
scvI256
➡️bigint
scvBytes
➡️Buffer
(or should it beUint8Array
?)scvString
➡️string
scvVec
➡️Array<T>
scvMap
➡️Map<ScVal, any>
, where eachScVal
is converted to its native type if possiblescvAddress
➡️Address
Some conversions are unclear and the value of an abstraction for them is a little unclear:
scvSymbol
scvContractExecutable
scvLedgerKeyContractExecutable
scvLedgerKeyNonce
scvStatus
Describe alternatives you've considered
Suffering.
Additional context
Original feature request from @piyalbasu here: stellar/js-soroban-client#43.
Discord discussion here: https://discord.com/channels/897514728459468821/1111621289900253245.
The text was updated successfully, but these errors were encountered: