You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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*asfclfrom @onflow/fclconstparams={"amount": "UFix64","to": "Address"}consttemplateURL="https://flix.flow.com/v1/templates?name=transfer-flow"exportasyncfunctionTemplateName({to, amount }){// check argument hashlethashMatches=false;lethasError=false;try{constresponse=awaitfetch(templateURL);// Check if the request was successfulif(response.ok){consttemplateData=awaitresponse.json();// Convert response to JSONdoesMatches=matchParams(templateData.parameters,params)}else{thrownewError(`Failed to fetch: ${response.status}${response.statusText}`);}}catch(error){console.error(error)// need better way to convey errors than console log and eathasError=true}if(!doesMatches)returnreturnrequest({to, amount});}asyncfunctionrequest({ to, amount }){consttransactionId=awaitfcl.mutate({template: templateURL,args: (arg,t)=>([arg(to,t.Address),arg(amount,t.UFix64)])})returntransactionId}
The text was updated successfully, but these errors were encountered:
bthaile
changed the title
[Improvement] Generate javascript and typescript bindings
Generate javascript and typescript bindings
Aug 10, 2023
Go has the ability to parse the program and get out information from it so i think go is the right choixe here. The code should also support generating go bindings.
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:
Sub Tasks:
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
The text was updated successfully, but these errors were encountered: