Skip to content

Commit

Permalink
Merge pull request #47 from dapperlabs/josh/reorg
Browse files Browse the repository at this point in the history
updated dependencies and contracts
  • Loading branch information
joshuahannan authored May 28, 2020
2 parents 393086d + 7835874 commit 92a4c97
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 116 deletions.
38 changes: 23 additions & 15 deletions contracts/topshot_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ package contracts
// flow core contracts files for use in go testing and deployment

import (
"io/ioutil"
"strings"

"github.com/onflow/flow-ft/fttest"

"github.com/onflow/flow-go-sdk"
)

const (
topshotFile = "./TopShot.cdc"
marketFile = "./MarketTopShot.cdc"
shardedCollectionFile = "./TopShotShardedCollection.cdc"
adminReceiverFile = "./TopShotAdminReceiver.cdc"
topshotFile = "../contracts/TopShot.cdc"
marketFile = "../contracts/MarketTopShot.cdc"
shardedCollectionFile = "../contracts/TopShotShardedCollection.cdc"
adminReceiverFile = "../contracts/TopShotAdminReceiver.cdc"
)

// GenerateTopShotContract returns a copy
// of the topshot contract with the import addresses updated
func GenerateTopShotContract(nftAddr flow.Address) []byte {

topShotCode := fttest.ReadFile(topshotFile)
codeWithNFTAddr := strings.ReplaceAll(string(topShotCode), "0x02", nftAddr.String())
topShotCode := ReadFile(topshotFile)
codeWithNFTAddr := strings.ReplaceAll(string(topShotCode), "02", nftAddr.String())

return []byte(codeWithNFTAddr)
}
Expand All @@ -32,9 +31,9 @@ func GenerateTopShotContract(nftAddr flow.Address) []byte {
// of the TopShotShardedCollectionContract with the import addresses updated
func GenerateTopShotShardedCollectionContract(nftAddr, topshotAddr flow.Address) []byte {

shardedCode := fttest.ReadFile(marketFile)
codeWithNFTAddr := strings.ReplaceAll(string(shardedCode), "0x02", nftAddr.String())
codeWithTopshotAddr := strings.ReplaceAll(string(codeWithNFTAddr), "0x03", topshotAddr.String())
shardedCode := ReadFile(shardedCollectionFile)
codeWithNFTAddr := strings.ReplaceAll(string(shardedCode), "02", nftAddr.String())
codeWithTopshotAddr := strings.ReplaceAll(string(codeWithNFTAddr), "03", topshotAddr.String())

return []byte(codeWithTopshotAddr)
}
Expand All @@ -43,9 +42,9 @@ func GenerateTopShotShardedCollectionContract(nftAddr, topshotAddr flow.Address)
// of the TopshotAdminReceiver contract with the import addresses updated
func GenerateTopshotAdminReceiverContract(topshotAddr, shardedAddr flow.Address) []byte {

adminReceiverCode := fttest.ReadFile(adminReceiverFile)
codeWithTopshotAddr := strings.ReplaceAll(string(adminReceiverCode), "0x03", topshotAddr.String())
codeWithShardedAddr := strings.ReplaceAll(string(codeWithTopshotAddr), "0x04", shardedAddr.String())
adminReceiverCode := ReadFile(adminReceiverFile)
codeWithTopshotAddr := strings.ReplaceAll(string(adminReceiverCode), "03", topshotAddr.String())
codeWithShardedAddr := strings.ReplaceAll(string(codeWithTopshotAddr), "04", shardedAddr.String())

return []byte(codeWithShardedAddr)
}
Expand All @@ -54,11 +53,20 @@ func GenerateTopshotAdminReceiverContract(topshotAddr, shardedAddr flow.Address)
// of the TopShotMarketContract with the import addresses updated
func GenerateTopShotMarketContract(fungibletokenAddr, flowtokenAddr, nftAddr, topshotAddr flow.Address) []byte {

marketCode := fttest.ReadFile(marketFile)
marketCode := ReadFile(marketFile)
codeWithFunTAddr := strings.ReplaceAll(string(marketCode), "0x04", fungibletokenAddr.String())
codeWithFlowTAddr := strings.ReplaceAll(string(codeWithFunTAddr), "0x05", flowtokenAddr.String())
codeWithNFTAddr := strings.ReplaceAll(string(codeWithFlowTAddr), "0x02", nftAddr.String())
codeWithTopshotAddr := strings.ReplaceAll(string(codeWithNFTAddr), "0x03", topshotAddr.String())

return []byte(codeWithTopshotAddr)
}

// ReadFile reads a file from the file system
func ReadFile(path string) []byte {
contents, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
return contents
}
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ module github.com/dapperlabs/nba-smart-contracts
go 1.13

require (
github.com/dapperlabs/flow-emulator v1.0.0-alpha.7.0.20200522225230-51e97f42cb03
github.com/dapperlabs/flow-go v0.3.2-0.20200520200337-3476e94b144b // indirect
github.com/dapperlabs/flow-emulator v0.4.0-beta1
github.com/dapperlabs/flow-go/protobuf v0.3.2-0.20200312195452-df4550a863b7 // indirect
github.com/dchest/siphash v1.2.1 // indirect
github.com/onflow/cadence v0.3.0-beta3.0.20200523010558-3fe40e24eeab
github.com/onflow/flow-ft v0.0.0-20200522195050-f52a75e639bf
github.com/onflow/flow-go-sdk v0.3.0-beta1
github.com/onflow/cadence v0.4.0-beta1
github.com/onflow/flow-go-sdk v0.4.0-beta1
github.com/onflow/flow-nft v0.0.0-20200528194639-18c29d3c8e3c
github.com/philhofer/fwd v1.0.0 // indirect
github.com/stretchr/testify v1.5.1
Expand Down
Loading

0 comments on commit 92a4c97

Please sign in to comment.