Skip to content

Commit

Permalink
update contract borrows and ExampleToken import
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Mar 5, 2024
1 parent 959b707 commit 29d91e1
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 142 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.12.0-cadence-v1.0.0-M4-2
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/feature/stable-cadence/install.sh)"
- name: Flow CLI Version
run: flow version
run: flow-c1 version
- name: Update PATH
run: echo "/root/.local/bin" >> $GITHUB_PATH
- name: Run tests
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
test:
$(MAKE) generate -C lib/go
$(MAKE) test -C lib/go
flow test --cover --covercode="contracts" tests/*.cdc
flow-c1 test --cover --covercode="contracts" tests/*.cdc

.PHONY: ci
ci:
$(MAKE) ci -C lib/go
flow test --cover --covercode="contracts" tests/*.cdc
flow-c1 test --cover --covercode="contracts" tests/*.cdc
1 change: 0 additions & 1 deletion contracts/ExampleToken.cdc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import FungibleToken from "FungibleToken"
import MetadataViews from "MetadataViews"
import FungibleTokenMetadataViews from "FungibleTokenMetadataViews"
import ViewResolver from "ViewResolver"

access(all) contract ExampleToken: FungibleToken {

Expand Down
1 change: 1 addition & 0 deletions contracts/FungibleToken.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ access(all) contract interface FungibleToken: ViewResolver {
post {
self.balance == 0.0: "The balance must be set to zero during the burnCallback method so that it cannot be spammed"
}
self.balance = 0.0
}

/// getSupportedVaultTypes optionally returns a list of vault types that this receiver accepts
Expand Down
142 changes: 73 additions & 69 deletions coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@
"coverage": {
"./contracts/ExampleToken.cdc": {
"line_hits": {
"101": 1,
"102": 1,
"103": 1,
"105": 1,
"109": 1,
"113": 5,
"104": 1,
"108": 1,
"112": 5,
"117": 0,
"118": 0,
"119": 0,
"120": 0,
"124": 0,
"129": 0,
"123": 0,
"128": 0,
"142": 7,
"143": 7,
"144": 7,
"156": 6,
"157": 6,
"158": 6,
"159": 6,
"160": 6,
"171": 0,
"18": 1,
"17": 1,
"170": 0,
"185": 1,
"186": 1,
"187": 1,
"188": 1,
"200": 9,
"204": 4,
"206": 4,
"210": 4,
"199": 9,
"203": 4,
"205": 4,
"209": 4,
"215": 4,
"216": 4,
"217": 4,
"218": 4,
"219": 4,
"221": 4,
"220": 4,
"222": 4,
"223": 4,
"224": 4,
"27": 47,
"29": 2,
"34": 4,
"26": 47,
"28": 2,
"33": 4,
"39": 4,
"40": 4,
"41": 4,
"52": 40,
"59": 3,
"63": 0,
"67": 1,
"51": 40,
"58": 3,
"62": 0,
"66": 1,
"92": 21,
"93": 21,
"94": 21,
"95": 21,
"96": 21,
"97": 21
"96": 21
},
"missed_lines": [
63,
62,
117,
118,
119,
120,
124,
129,
171
123,
128,
170
],
"statements": 46,
"percentage": "84.8%"
Expand All @@ -66,30 +66,32 @@
"100": 7,
"148": 1,
"151": 1,
"162": 0,
"153": 0,
"163": 0,
"167": 0,
"173": 0,
"181": 8,
"185": 7,
"189": 15,
"200": 6,
"202": 6,
"205": 18,
"214": 0,
"223": 9,
"164": 0,
"168": 0,
"174": 0,
"182": 8,
"186": 7,
"190": 15,
"201": 6,
"203": 6,
"206": 18,
"215": 0,
"224": 9,
"225": 9,
"98": 7
},
"missed_lines": [
162,
153,
163,
167,
173,
214
164,
168,
174,
215
],
"statements": 17,
"percentage": "70.6%"
"statements": 18,
"percentage": "66.7%"
},
"./contracts/FungibleTokenMetadataViews.cdc": {
"line_hits": {
Expand Down Expand Up @@ -588,28 +590,30 @@
}
},
"excluded_locations": [
"A.0000000000000002.FungibleToken",
"A.0000000000000001.FlowEpoch",
"s.7465737400000000000000000000000000000000000000000000000000000000",
"A.0000000000000003.FlowToken",
"A.0000000000000001.NonFungibleToken",
"I.Test",
"A.0000000000000001.RandomBeaconHistory",
"A.0000000000000001.FlowServiceAccount",
"A.0000000000000001.NodeVersionBeacon",
"A.0000000000000002.FungibleTokenMetadataViews",
"A.0000000000000001.ExampleNFT",
"A.0000000000000004.FlowFees",
"A.0000000000000001.FlowDKG",
"A.0000000000000002.FungibleTokenSwitchboard",
"A.0000000000000001.FlowStakingCollection",
"A.0000000000000001.FlowIDTableStaking",
"A.0000000000000001.StakingProxy",
"A.0000000000000001.FlowStorageFees",
"A.0000000000000001.FlowClusterQC",
"A.0000000000000001.MetadataViews",
"A.0000000000000001.FlowServiceAccount",
"A.0000000000000001.NonFungibleToken",
"A.0000000000000001.EVM",
"A.0000000000000002.FungibleToken",
"A.0000000000000001.ViewResolver",
"I.Crypto",
"s.7465737400000000000000000000000000000000000000000000000000000000",
"A.0000000000000001.LockedTokens",
"A.0000000000000001.ViewResolver",
"A.0000000000000001.MetadataViews",
"I.BlockchainHelpers"
"A.0000000000000001.FlowDKG",
"A.0000000000000001.FlowEpoch",
"A.0000000000000001.ExampleNFT",
"I.Test",
"I.BlockchainHelpers",
"A.0000000000000001.FlowStorageFees",
"A.0000000000000001.FlowIDTableStaking",
"A.0000000000000002.FungibleTokenMetadataViews",
"A.0000000000000001.FlowClusterQC",
"A.0000000000000001.NodeVersionBeacon",
"A.0000000000000001.RandomBeaconHistory",
"A.0000000000000001.StakingProxy"
]
}
3 changes: 1 addition & 2 deletions lib/go/contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ func FungibleTokenSwitchboard(fungibleTokenAddr string) []byte {
// ExampleToken returns the second version of the ExampleToken contract.
//
// The returned contract will import the FungibleToken interface from the specified address.
func ExampleToken(fungibleTokenAddr, metadataViewsAddr, ftMetadataViewsAddr, viewResolverAddr string) []byte {
func ExampleToken(fungibleTokenAddr, metadataViewsAddr, ftMetadataViewsAddr string) []byte {
code := assets.MustAssetString(filenameExampleToken)

code = placeholderFungibleToken.ReplaceAllString(code, "0x"+fungibleTokenAddr)
code = placeholderMetadataViews.ReplaceAllString(code, "0x"+metadataViewsAddr)
code = placeholderFTMetadataViews.ReplaceAllString(code, "0x"+ftMetadataViewsAddr)
code = placeholderViewResolver.ReplaceAllString(code, "0x"+viewResolverAddr)

return []byte(code)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/go/contracts/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestFungibleTokenContract(t *testing.T) {
}

func TestExampleTokenContract(t *testing.T) {
contract := contracts.ExampleToken(addrA, addrA, addrA, addrA)
contract := contracts.ExampleToken(addrA, addrA, addrA)
assert.NotNil(t, contract)
assert.Contains(t, string(contract), addrA)
}
Expand Down
12 changes: 6 additions & 6 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

Loading

0 comments on commit 29d91e1

Please sign in to comment.