How does one use getTableItem (TS SDK) against a Table with inner vector data? #157
-
Describe your question in detail.Asked by
Where they then ask how to supply MoveType's to getTableItem. What error, if any, are you getting?
What have you tried or looked at? Or how can we reproduce the error?
Which operating system are you using?N/A Which SDK or tool are you using? (if any)TypeScript SDK Describe your environment or tooling in detailNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Two Problems Identified1. key_typeFor A reminder, String is a struct, not a primitive type (e.g. integers and others). 2. value_type
Solutions1. key_typeIn your example, it would require changes from:
to:
I derived this struct reference from the Move reference documentation on Move-stdlib's string. 2. value_typeYou'll need to include the vector as part of the string, resulting in changes from:
to:
Useful links
Additionally, here's the snippet of Typescript code to retrieve the Table entry from the Testnet demonstration:
which results in: |
Beta Was this translation helpful? Give feedback.
Two Problems Identified
1. key_type
For
key_type
ingetTableItem
, you'll need to provide the full struct reference, as defined by MoveType.A reminder, String is a struct, not a primitive type (e.g. integers and others).
2. value_type
value_type
is also misrepresented, since your table contains avector
ofAsset
, and not just a singleAsset
.Solutions
1. key_type
In your example, it would require changes from:
to:
I derived this struct reference from the Move reference documentation on Move-stdlib's string.
2. value_type
You'll need to include the vector as part of the string, resulting in changes from: