Skip to content

Commit

Permalink
update to filter networks when generating flix, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bthaile committed Apr 18, 2024
1 parent ea811d2 commit d579487
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 35 deletions.
12 changes: 7 additions & 5 deletions internal/v1_1/generator.go
Expand Up @@ -129,7 +129,7 @@ func (g Generator) CreateTemplate(ctx context.Context, code string, preFill stri
}

// need to process dependencies before calculating network pins
_ = g.calculateNetworkPins(program)
_ = g.calculateNetworkPins()
id, _ := GenerateFlixID(g.template)
g.template.ID = id
templateJson, err := json.MarshalIndent(g.template, "", " ")
Expand All @@ -138,11 +138,13 @@ func (g Generator) CreateTemplate(ctx context.Context, code string, preFill stri

}

func (g Generator) calculateNetworkPins(program *ast.Program) error {
networksOfInterest := []string{
config.MainnetNetwork.Name,
config.TestnetNetwork.Name,
func (g Generator) calculateNetworkPins() error {
networksOfInterest := []string{}
// only interested in the client networks
for _, client := range g.clients {
networksOfInterest = append(networksOfInterest, client.Network().Name)
}

networkPins := make([]NetworkPin, 0)
for _, netName := range networksOfInterest {
cad, err := g.template.ReplaceCadenceImports(netName)
Expand Down
11 changes: 1 addition & 10 deletions internal/v1_1/testdata/TestHelloScript.golden
Expand Up @@ -27,16 +27,7 @@
],
"cadence": {
"body": "\n\t#interaction(\n\t\tversion: \"1.1.0\",\n\t\ttitle: \"Say Hello\",\n\t\tdescription: \"Read the greeting from the HelloWorld contract\",\n\t\tlanguage: \"en-US\",\n\t\tparameters: [],\n\t)\n\n\timport \"HelloWorld\"\n\n\taccess(all)\n\tfun main(): String {\n\t\treturn HelloWorld.greeting\n\t}\n",
"network_pins": [
{
"network": "mainnet",
"pin_self": "ab7702bc218a403fde58f290a89105f5c16d1462e1aedf19a73e2eb6d924245c"
},
{
"network": "testnet",
"pin_self": "ab7702bc218a403fde58f290a89105f5c16d1462e1aedf19a73e2eb6d924245c"
}
]
"network_pins": []
},
"dependencies": [
{
Expand Down
11 changes: 1 addition & 10 deletions internal/v1_1/testdata/TestTransactionValue.golden
Expand Up @@ -27,16 +27,7 @@
],
"cadence": {
"body": "\n\t#interaction(\n\t\tversion: \"1.1.0\",\n\t\ttitle: \"Update Greeting\",\n\t\tdescription: \"Update the greeting on the HelloWorld contract\",\n\t\tlanguage: \"en-US\",\n\t\tparameters: [\n\t\t\tParameter(\n\t\t\t\tname: \"greeting\",\n\t\t\t\ttitle: \"Greeting\",\n\t\t\t\tdescription: \"The greeting to set on the HelloWorld contract\"\n\t\t\t)\n\t\t],\n\t)\n\n\timport \"HelloWorld\"\n\n\ttransaction(greeting: String) {\n\n\t\tprepare(acct: \u0026Account) {\n\t\t\tlog(acct.address)\n\t\t}\n\n\t\texecute {\n\t\t\tHelloWorld.updateGreeting(newGreeting: greeting)\n\t\t}\n\t}\n",
"network_pins": [
{
"network": "mainnet",
"pin_self": "7a7b3ffbc205913afdd4d48e60a96ad1e5ecd2f2d29c4a1331a72182f63c90ff"
},
{
"network": "testnet",
"pin_self": "7a7b3ffbc205913afdd4d48e60a96ad1e5ecd2f2d29c4a1331a72182f63c90ff"
}
]
"network_pins": []
},
"dependencies": [
{
Expand Down
11 changes: 1 addition & 10 deletions internal/v1_1/testdata/TestTransferFlowTransaction.golden
Expand Up @@ -27,16 +27,7 @@
],
"cadence": {
"body": "\n\t#interaction(\n\t\tversion: \"1.1.0\",\n\t\ttitle: \"Transfer Flow\",\n\t\tdescription: \"Transfer Flow to account\",\n\t\tlanguage: \"en-US\",\n\t\tparameters: [\n\t\t\tParameter(\n\t\t\t\tname: \"amount\",\n\t\t\t\ttitle: \"Amount\",\n\t\t\t\tdescription: \"Amount of Flow to transfer\"\n\t\t\t),\n\t\t\tParameter(\n\t\t\t\tname: \"to\",\n\t\t\t\ttitle: \"Receiver\",\n\t\t\t\tdescription: \"Destination address to receive Flow Tokens\"\n\t\t\t)\n\t\t],\n\t)\n\n\timport \"FlowToken\"\n\n\ttransaction(amount: UFix64, to: Address) {\n\t\tlet vault: @FlowToken.Vault\n\n\t\tprepare(signer: \u0026Account) {}\n\t}\n",
"network_pins": [
{
"network": "mainnet",
"pin_self": "8f51a4190c0b607f96eb65cc88e9335079aa659c4af7c858ef2de0a2171f7c4b"
},
{
"network": "testnet",
"pin_self": "76920dd3758b4ee3ee8a8929d05f3e4067f66a30b272f518a14bba504fefd4b1"
}
]
"network_pins": []
},
"dependencies": [
{
Expand Down

0 comments on commit d579487

Please sign in to comment.