Skip to content

Sadie/remove sharded contract & update addresses #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# NFL Smart Contracts

## NFL Contract Addresses
| Testnet | TBC |
| Mainnet | TBC |
| Testnet | e4cf4bdc1751c65d | [Flow View Source](https://flow-view-source.com/mainnet/account/0xe4cf4bdc1751c65d)
| Mainnet | 4dfd62c88d1b6462 | [Flow View Source](https://flow-view-source.com/testnet/account/0x4dfd62c88d1b6462)

## Entities

Expand Down
173 changes: 0 additions & 173 deletions contracts/AllDayShardedCollection.cdc

This file was deleted.

112 changes: 0 additions & 112 deletions lib/go/test/allday_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,115 +538,3 @@ func testMintMomentNFT(
assert.Equal(t, previousSupply, newSupply)
}
}

//------------------------------------------------------------
// ShardedCollection
// ------------------------------------------------------------
func TestShardedCollection(t *testing.T) {
b := newEmulator()

contracts := AllDayDeployContracts(t, b)
// Set up for NFT Minting
createTestEditions(t, b, contracts)
user1Address, user1Signer := createAccount(t, b)
user2Address, user2Signer := createAccount(t, b)
numMomentNFTs := uint64(20)

t.Run("Creating a sharded collection should work", func(t *testing.T) {
setupShardedCollection(
t,
b,
contracts,
user1Address,
user1Signer,
uint64(75),
false,
)
})

t.Run("Creating a sharded collection twice for the same address should not work", func(t *testing.T) {
setupShardedCollection(
t,
b,
contracts,
user1Address,
user1Signer,
uint64(75),
true,
)
})

t.Run("Minting to a sharded collection should work", func(t *testing.T) {
numMomentNFTsAlready := getMomentNFTSupply(t, b, contracts)
for i := uint64(1); i < numMomentNFTs; i++ {
testMintMomentNFT(
t,
b,
contracts,
uint64(2),
user1Address,
uint64(numMomentNFTsAlready+i),
uint64(numMomentNFTsAlready+i),
false,
)
}
})

t.Run("Transferring from a sharded collection to a collection should work", func(t *testing.T) {
setupAllDay(t, b, user2Address, user2Signer, contracts)
// Transfer the first 10 moments from ShardedCollection to Collection
for i := uint64(1); i <= 10; i++ {
transferMomentNFTFromShardedCollection(
t,
b,
contracts,
user1Address,
user1Signer,
i,
user2Address,
false,
)
}
})

t.Run("Batch transferring from a sharded collection to a collection should work", func(t *testing.T) {
user2Address, user2Signer := createAccount(t, b)
setupAllDay(t, b, user2Address, user2Signer, contracts)

// Make the list of IDs to transfer
nftIDs := []uint64{}
for i := uint64(11); i < 20; i++ {
nftIDs = append(nftIDs, i)
}
// Transfer the next 10 moments from ShardedCollection to Collection
batchTransferMomentNFTsFromShardedCollection(
t,
b,
contracts,
user1Address,
user1Signer,
nftIDs,
user2Address,
false,
)
})

t.Run("Transferring from a collection to a collection should work", func(t *testing.T) {
user3Address, user3Signer := createAccount(t, b)
setupAllDay(t, b, user3Address, user3Signer, contracts)

// Transfer the first 10 moments from Collection to Collection
for i := uint64(1); i <= 10; i++ {
transferMomentNFT(
t,
b,
contracts,
user2Address,
user2Signer,
i,
user3Address,
false,
)
}
})
}
50 changes: 2 additions & 48 deletions lib/go/test/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
// Handle relative paths by making these regular expressions

const (
nftAddressPlaceholder = "\"[^\"]*NonFungibleToken.cdc\""
AllDayAddressPlaceholder = "\"[^\"]*AllDay.cdc\""
AllDayShardedCollectionAddressPlaceholder = "\"[^\"]*AllDayShardedCollection.cdc\""
nftAddressPlaceholder = "\"[^\"]*NonFungibleToken.cdc\""
AllDayAddressPlaceholder = "\"[^\"]*AllDay.cdc\""
)

const (
Expand All @@ -23,12 +22,6 @@ const (
AllDaySetupAccountPath = AllDayTransactionsRootPath + "/user/setup_AllDay_account.cdc"
AllDayAccountIsSetupPath = AllDayScriptsRootPath + "/user/account_is_setup.cdc"

// ShardedCollection
AllDayShardedCollectionPath = "../../../contracts/AllDayShardedCollection.cdc"
AllDaySetupShardedCollectionPath = AllDayTransactionsRootPath + "/admin/sharded_collection/setup_sharded_collection.cdc"
AllDayTransferMomentNFTFromShardedCollectionPath = AllDayTransactionsRootPath + "/admin/sharded_collection/transfer_AllDay_nft_from_sharded_collection.cdc"
AllDayBatchTransferMomentNFTsFromShardedCollectionPath = AllDayTransactionsRootPath + "/admin/sharded_collection/batch_transfer_AllDay_nfts_from_sharded_collection.cdc"

// Series
AllDayCreateSeriesPath = AllDayTransactionsRootPath + "/admin/series/create_series.cdc"
AllDayCloseSeriesPath = AllDayTransactionsRootPath + "/admin/series/close_series.cdc"
Expand Down Expand Up @@ -75,9 +68,6 @@ func replaceAddresses(code []byte, contracts Contracts) []byte {
AllDayRe := regexp.MustCompile(AllDayAddressPlaceholder)
code = AllDayRe.ReplaceAll(code, []byte("0x"+contracts.AllDayAddress.String()))

AllDayShardedCollectionRe := regexp.MustCompile(AllDayShardedCollectionAddressPlaceholder)
code = AllDayShardedCollectionRe.ReplaceAll(code, []byte("0x"+contracts.AllDayShardedCollectionAddress.String()))

return code
}

Expand All @@ -104,42 +94,6 @@ func loadAllDayAccountIsSetupScript(contracts Contracts) []byte {
)
}

//------------------------------------------------------------
// Sharded Collection
//------------------------------------------------------------
func loadAllDayShardedCollection(nftAddress flow.Address, AllDayAddress flow.Address) []byte {
code := readFile(AllDayShardedCollectionPath)

nftRe := regexp.MustCompile(nftAddressPlaceholder)
code = nftRe.ReplaceAll(code, []byte("0x"+nftAddress.String()))

AllDayRe := regexp.MustCompile(AllDayAddressPlaceholder)
code = AllDayRe.ReplaceAll(code, []byte("0x"+AllDayAddress.String()))

return code
}

func loadAllDaySetupShardedCollectionTransaction(contracts Contracts) []byte {
return replaceAddresses(
readFile(AllDaySetupShardedCollectionPath),
contracts,
)
}

func loadAllDayTransferMomentNFTFromShardedCollectionTransaction(contracts Contracts) []byte {
return replaceAddresses(
readFile(AllDayTransferMomentNFTFromShardedCollectionPath),
contracts,
)
}

func loadAllDayBatchTransferMomentNFTsFromShardedCollectionTransaction(contracts Contracts) []byte {
return replaceAddresses(
readFile(AllDayBatchTransferMomentNFTsFromShardedCollectionPath),
contracts,
)
}

//------------------------------------------------------------
// Series
//------------------------------------------------------------
Expand Down
Loading