Skip to content

Multiline Arguments and Optionals

Compare
Choose a tag to compare
@MaxStalker MaxStalker released this 20 Sep 16:27
9c050e8

⭐ Multiline Arguments

Parser now supports multiline arguments for scripts and transactions. Code like this will work properly now:

transaction(
    a: UInt,
    b: UInt,
    sum: UInt){

   prepare(signer: AuthAccount){
       assert(a + b == sum, "wrong!")
   }
}

## ⭐ Added support for Optionals
Optional types are now supported with methods `mapArgument`, `mapArguments` and `mapValuesToCode`. 
```javascript
import { query } from "@onflow/fcl";
import { mapValuesToCode } from "flow-cadut";

(async ()=>{
   const cadence = `
       pub fun main(message: String?): String?{
           return message
       }
   `
   const args = () => mapValuesToCode(["Hello, Cadence"])
   // or you can pass "null" for empty value
   // const args = () => mapValuesToCode([null])

   const result = await query({ cadence, args})
   console.log({result})
})()