onflow / flow-interaction-template-tools

Apache License 2.0
6 stars 0 forks source link

[BUG] Multi-network template generation fails #13

Open bartolomej opened 6 months ago

bartolomej commented 6 months ago

Current Behavior

Calling await FLIXGenerators.template(...) with dependencies from multiple networks (testnet and mainnet) will result in error:

 throw new HTTPRequestError({
            ^

HTTPRequestError [HTTP Request Error]: 
      HTTP Request Error: An error occurred when interacting with the Access API.
      error=rpc error: code = InvalidArgument desc = address 8f9231920da9af6d is invalid for chain flow-testnet
      hostname=https://rest-testnet.onflow.org
      path=/v1/accounts/8f9231920da9af6d?block_height=138556193&expand=contracts,keys
      method=GET

      responseBody={
        "code": 400,
        "message": "rpc error: code = InvalidArgument desc = address 8f9231920da9af6d is invalid for chain flow-testnet"
}
      responseStatusText=Bad Request
      statusCode=400

Expected Behavior

I understand this is probably happening because I can only configure FCL for one network at a time (which I need to do to call FLIXGenerators.template), so it can't resolve addresses from other networks.

But I wonder if there is a way we could avoid this limitation so that multi-network template generation would still work in this way.

Otherwise, I believe developers would need to first generate templates for each network separately and then combine them.

For reference, this is the code I'm using: https://github.com/blocto/flow-transactions/pull/60.

Steps To Reproduce

Run this script: https://github.com/onflowser/blocto-flow-transactions/blob/flix-migration/internal/migrateToFlix.js

What are you currently working on that this is blocking?

I'm trying to migrate Blocto's transaction collection to FLIX (https://github.com/blocto/flow-transactions/issues/59).

bthaile commented 6 months ago

would it be easier to use flow-cli to generate flix, it uses flow.json, if deployed contracts are configured then the flix will be populated for all networks.

https://developers.flow.com/tools/flow-cli/flix

Also, we are working on flix version 1.1, which has a different structure. I'll be released using flow-cli initially. Not sure when fcl will support flix version 1.1.

bartolomej commented 6 months ago

would it be easier to use flow-cli to generate flix, it uses flow.json, if deployed contracts are configured then the flix will be populated for all networks.

Hmm, looks like this could work if we generate flow.json with deployed contracts info instead of providing that to the dependencies array directly when using flow-interaction-template-tools. But that would require a re-implementation of the current migration script in our specific use case.

Will try that out!

Also, we are working on flix version 1.1, which has a different structure. I'll be released using flow-cli initially. Not sure when fcl will support flix version 1.1.

I'm aware of that. My hope is that I can generate FLIX v1.0 structure and merge it to https://github.com/onflow/flow-interaction-template-service repo to be stored with other FLIX v1.0 templates. And later we could write another migration script to migrate all FLIX v1.0 templates to FLIX v1.1.