[BUG] Interaction template objects don't work in `fcl.query` method
nichita-rusin opened this issue · comments
Current Behavior
Calling fcl.query
with an interaction template object returns an error:
Error: FCL configureDependencies Error: Unsupported template version
at deriveDependencies (C:\flow\node_modules\@onflow\fcl-core\dist\fcl-core.js:423:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async prepTemplateOpts (C:\flow\node_modules\@onflow\fcl-core\dist\fcl-core.js:436:20)
at async Module.query (C:\flow\node_modules\@onflow\fcl-core\dist\fcl-core.js:501:10)
This error occurs regardless of the value of the f_version
field in the template.
Expected Behavior
Calling fcl.query
with an interaction template object returns the execution result.
Steps To Reproduce
I used the following template with the goal of getting a list of staking nodes on testnet:
{
"f_type": "InteractionTemplate",
"f_version": "1.1.0",
"id": "000",
"data": {
"type": "transaction",
"interface": "",
"messages": [
{
"key": "title",
"i18n": [
{
"tag": "en-US",
"translation": "Get Stakig Nodes"
}
]
},
{
"key": "description",
"i18n": [
{
"tag": "en-US",
"translation": "Get a list of staking nodes for the current epoch"
}
]
}
],
"cadence": {
"body": "import \"FlowIDTableStaking\"\n// This script gets all the info about all nodes and returns it\n\npub fun main(): [FlowIDTableStaking.NodeInfo] {\nlet staked_nodes = FlowIDTableStaking.getStakedNodeIDs()\nlet node_info: [FlowIDTableStaking.NodeInfo] = []\nfor node in staked_nodes {\nnode_info.append(FlowIDTableStaking.NodeInfo(node))\n}\nreturn node_info\n}"
},
"dependencies": [
{
"contracts": [
{
"contract": "FlowIDTableStaking",
"networks": [
{
"address": "0x9eca2b38b18b5dfe",
"network": "testnet"
}
]
}
]
}
],
"arguments": {}
}
}
I called it like this:
import * as fcl from "@onflow/fcl";
fcl.config({
"accessNode.api": "https://access-testnet.onflow.org",
"discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn",
"flow.network": "testnet"
})
fcl.query({
template: template
}).then(result =>
console.table(result.map(r => ({ id: r.id, networkAddress: r.networkingAddress })))
)
Environment
- OS: Windows 11
- Node: 18.12.1
- yarn: 1.22.19
- @onflow/fcl: 1.10.1
What are you currently working on that this is blocking?
No response
The issue seems to be caused by some missing await
s in prepTemplateOpts on lines 15 and 21. This means that fcl.mutate()
is also affected by this bug. I will try to publish a PR for this shortly.