Generate fcl-js binding files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 0
- Forks
- 7
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 2
Description
Given a interactive template (flix) need to create binding files. Task should address local development.
In current Cadence vs code project structure, bindings files can be generated to "bindings" folder by default.
For CLI configuration user passes in "Cadence" folder and all transactions and scripts will be discovered and templates generated to "templates" directory and binding generated to "bindings" folder.
Tasks:
- Generate plain vanilla Javascript
- handle both local & remote
- Generate js docs (typescript)
- handle both local & remote
- Generate Golang (tracked in https://github.com/onflow/flixkit-go/issues/17)
Sub Tasks:
- verify parameters have not changed at run time
- FLIX template file is pulled in at runtime.
- Bindings only need to change if arguments changed or contract addresses.
- Handle structs as arguments
- Handle complex built-in Cadence types
Note:
Reference: Cadut uses handlebar templates to generate javascript files.
Binding should have a hash template interface (arguments) and verify the hash has not changed at runtime.
Example javascript binding that uses a URL to flix
import * as fcl from @onflow/fcl
const params = { "amount": "UFix64", "to": "Address"}
const templateURL = "https://flix.flow.com/v1/templates?name=transfer-flow"
export async function TemplateName({to, amount }) {
// check argument hash
let hashMatches = false;
let hasError = false;
try {
const response = await fetch(templateURL);
// Check if the request was successful
if (response.ok) {
const templateData = await response.json(); // Convert response to JSON
doesMatches = matchParams(templateData.parameters, params)
} else {
throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
}
} catch (error) {
console.error(error) // need better way to convey errors than console log and eat
hasError = true
}
if (!doesMatches) return
return request({to, amount});
}
async function request({ to, amount }) {
const transactionId = await fcl.mutate({
template: templateURL,
args: (arg, t) => ([ arg(to, t.Address), arg(amount, t.UFix64)])
})
return transactionId
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no implementation files or tests. Start by reviewing the existing Cadence VS Code project structure, the Flix template flow, and the Cadut Handlebars reference. Clarify the remaining scope around runtime parameter-hash verification, struct arguments, and complex built-in types; done should include those unchecked subtasks, while Golang generation is tracked separately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, javascript, typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100