can i export scale file from ts so can import it in rust? #180
Unanswered
dzmitry-lahoda
asked this question in
Q&A
Replies: 2 comments
-
Answer for other package is NO unstoppablejs/unstoppablejs#26 |
Beta Was this translation helpful? Give feedback.
0 replies
-
There isn't anything built-in to do this, but shapes come with metadata that you can use for this; e.g.: const visitor = new $.ShapeVisitor<string>()
visitor.add($.int, (_, signed, size) => signed ? `i${size}` : `u${size}`)
visitor.add($.array, (_, $el) => `Vec<${visitor.visit($el)}>`)
visitor.add($.str, () => "String")
visitor.add(
$.tuple,
(_, ...$els) =>
$els.length === 1
? `(${visitor.visit($els[0]!)},)`
: `(${$els.map((x) => visitor.visit(x)).join(", ")})`,
)
visitor.visit($.tuple($.array($.u8), $.str)) // "(Vec<u8>, String)" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have TS code using subshape. It defines SCALE shema. How I can export it to scale file?
I want to use scale parser from subxt to get rust code generated for that.
Beta Was this translation helpful? Give feedback.
All reactions