Open redDwarf03 opened 1 month ago
Summary: The user wants to convert a List<Map>
to a JSArray<JSAny>
for use with the WriteContractParameters
class, but they are unsure how to do this conversion. The user is working with a file containing a list of Map
objects, each representing a function signature for a smart contract.
It works when i hardcode...
final writeContractParameters = WriteContractParameters(
abi: [
{
"inputs".toJS: [
{
"internalType".toJS: "address".toJS,
"name".toJS: "spender".toJS,
"type".toJS: "address".toJS
},
{
"internalType".toJS: "uint256".toJS,
"name".toJS: "amount".toJS,
"type".toJS: "uint256".toJS
}
],
"name".toJS: "approve".toJS,
"outputs".toJS: [
{
"internalType".toJS: "bool".toJS,
"name".toJS: "".toJS,
"type".toJS: "bool".toJS
}
],
"stateMutability".toJS: "nonpayable".toJS,
"type".toJS: "function".toJS
}.jsify(),
].toJS);
If it's a List<Map>
, you can just call jsify()
on that object and cast the result to JSArray<JSObject>
. jsify
will do a recursive conversion on the strings, Maps, and Lists.
I have a file (an ABI file) with a list of
Map
I load the file in a List
The file :