Skip to content

Commit

Permalink
skip built-in contract imports
Browse files Browse the repository at this point in the history
  • Loading branch information
bartolomej committed Sep 5, 2024
1 parent 475cf28 commit 6aebe72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 48 deletions.
7 changes: 7 additions & 0 deletions internal/v1_1/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ func (g Generator) processDependencies(ctx context.Context, program *ast.Program
// fill in dependence information
g.template.Data.Dependencies = make([]Dependency, 0)
for _, imp := range imports {

// Built-in contracts imports are represented with identifier location
_, isBuiltInContract := imp.Location.(common.IdentifierLocation)
if isBuiltInContract {
continue
}

contractName := imp.Location.String()
networks, err := g.generateDependenceInfo(ctx, contractName)
if err != nil {
Expand Down
23 changes: 3 additions & 20 deletions internal/v1_1/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,6 @@ func TestValidImports(t *testing.T) {
},
},
},
{
Contract: "Joe",
Networks: []Network{
{
Network: "testnet",
Address: "0x0000000000000003",
},
{
Network: "mainnet",
Address: "0x0000000000000003",
},
{
Network: "emulator",
Address: "0x0000000000000003",
},
},
},
}

generator := Generator{
Expand All @@ -122,9 +105,9 @@ func TestValidImports(t *testing.T) {

assert := assert.New(t)
code := `
import Alice
import "Bob"
import Joe from 0x0000000000000003
import "Alice"
import Bob from 0x0000000000000002
import Joe
access(all)
fun main(): Void {}
Expand Down
32 changes: 4 additions & 28 deletions internal/v1_1/testdata/TestValidImports.golden
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
`{
"f_type": "InteractionTemplate",
"f_version": "1.1.0",
"id": "7a7046a0687195fa5a5dd3838fbb9a707e2b9f699e56eac9999b5cfea02b3d09",
"id": "585d2dd4fc3523ba140fbe0f798c07f1d4c3792aaed72a3b0d7c32c23a6457e7",
"data": {
"type": "script",
"interface": "",
"messages": null,
"cadence": {
"body": "\n\timport Alice\n\timport \"Bob\"\n\timport \"Joe\"\n\n\taccess(all)\n\tfun main(): Void {}\n",
"body": "\n\timport \"Alice\"\n\timport \"Bob\"\n\timport Joe\n\n\taccess(all)\n\tfun main(): Void {}\n",
"network_pins": []
},
"dependencies": [
Expand Down Expand Up @@ -58,30 +58,6 @@
]
}
]
},
{
"contracts": [
{
"contract": "Joe",
"networks": [
{
"network": "testnet",
"address": "0x0000000000000003",
"dependency_pin_block_height": 0
},
{
"network": "mainnet",
"address": "0x0000000000000003",
"dependency_pin_block_height": 0
},
{
"network": "emulator",
"address": "0x0000000000000003",
"dependency_pin_block_height": 0
}
]
}
]
}
],
"parameters": null,
Expand All @@ -92,4 +68,4 @@
"messages": []
}
}
}
}`

0 comments on commit 6aebe72

Please sign in to comment.