Sway now has the String
type, and some callable functions of smart contracts might return strings, like the function name in the SRC20 standard.
When using typescript sdk ABI typegen, for such functions it generates typescript functions with the return parameter of type StringOutput
, which is a type that is also generated by the typegen:
export type RawBytesOutput = { ptr: BN, cap: BN };
export type BytesOutput = { buf: RawBytesOutput, len: BN };
export type StringOutput = { bytes: BytesOutput };
How to convert StringOutput
to typescript’s string
?
The versions I used to generate the typescript wrapper:
Fuels version: 0.60.0
Forc version: 0.44.0
Fuel-Core version: 0.20.5
The reverse question is also actual: how to convert typescript’s strings to StringInput
in order to pass them to smart contract functions?