Releases: onflow/flow-cadut
Improved Interactions
There are several improvements to interactions - specifically it's possible to return raw values from executeScript
and wait for specific status on transaction.
Improved Argument Resolver and Code Splitting
⭐ Argument Resolver Updated
For this version we overhauled how complex arguments are being resolved. So now it's possible to pass an array of dictionaries and it will be properly resolved according to it's types.
⭐ Generator logic isolated
We isolated generator logic into a submodule, which should reduce amount of build errors, when flow-cadut
is included as dependency.
Big thanks to @jciruolo for bringing his case and working on package improvements!
Contract Init Arguments
Parser now support extraction of arguments for contract initializer:
const code = `
pub contract Hello{
init(a: String, b: Int) {
log(a)
log(b)
}
}
`
const params = await extractContractParameters(code);
/* params now contains object
{
contractName: "Hello",
args: "a: String, b: Int"
}
*/
Fixed Arguments Parser
Arguments Parser
There was a minor issue with arguments parser, due to which parser could incorrectly process template. This release includes fixes for this.
Multiline Arguments and Optionals
⭐ 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})
})()
Improved Complex Type Support
This update fixes several issues with complex types - Dictionaries and Arrays - and provides better test coverage for methods, responsible for parsing and argument resolving.
Major Refactoring
⭐️ GitHub Repositories
flow-generate
now supports GitHub repositories. Grab a url from your browser, which points to your repo, branch and/or folder - for, example here's one for Flow core-contracts - pass it as first argument in CLI call (or specify -i
/ --input
flag) and press enter!
flow-generate https://github.com/onflow/flow-core-contracts/tree/master/contracts ./src/generated
⭐️ Contract Templates Support
This version will also properly treat contract templates, creating deploy methods for you and properly exporting them.
⭐️ No Testing Dependency
We've cleaned up the code and removed dependency on flow-js-testing
, making it's easier to maintain and import into your projects.
Update argument matchers
Fixed Arguments Matchers
In previous version it was possible that regexp matchers, adjusted to catch transaction and script arguments would report false positive result encountering transaction
keyword in the comments. We have fixed them and now they shall behave properly.
Map Arguments
Added argument mappers
mapArgument
, mapArguments
and mapValuesToCode
are added to a list of exported methods.
Unused imports
Remove reportMissing
method import from templates.
This was triggering linter to throw an error. Now it's fixed!