Skip to content
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

FEATURE: V2 NonFungibleToken Standard #126

Merged
merged 128 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
a1a099d
first work on new standard
joshuahannan Jul 20, 2022
d418112
first draft of v2 NFT standard
joshuahannan Sep 9, 2022
6c03134
add type parameter to createEmptyCollection
joshuahannan Sep 9, 2022
cca2732
merge from master
joshuahannan Sep 12, 2022
926e46e
PR comments
joshuahannan Sep 12, 2022
f59902e
PR comments
joshuahannan Sep 27, 2022
e1bb168
make test
joshuahannan Sep 27, 2022
052d03a
move everything into the interface
joshuahannan Oct 5, 2022
ebdbb60
use getID and proper transfer
joshuahannan Oct 18, 2022
b7bc90b
use views in events, return optionals, and dont hardcode
joshuahannan Dec 6, 2022
3b8189e
add createEmptyCollection
joshuahannan Dec 16, 2022
340850c
isAcceptedType
joshuahannan Feb 1, 2023
7161f65
mar13 update
joshuahannan Mar 13, 2023
dc3a6f8
PR comments
joshuahannan Mar 23, 2023
bd8478f
separate nft views, add uuid, event args, resolver, and get contracts…
joshuahannan Apr 12, 2023
8f515ed
use events in interfaces
joshuahannan May 2, 2023
5a6b13e
integrate stable cadence changes
joshuahannan Jul 18, 2023
0d498ec
comment out events
joshuahannan Jul 18, 2023
4a745a6
modify view functions
joshuahannan Jul 18, 2023
98f7669
remove deposit impl
joshuahannan Jul 18, 2023
31bc26c
remove view from dictToTraits
joshuahannan Jul 18, 2023
ec3eda1
remove view modifier from resolveView
joshuahannan Jul 19, 2023
3f1e70b
remove restricted types
joshuahannan Jul 26, 2023
10f298c
remove AnyStruct
joshuahannan Jul 26, 2023
e12c049
update dependencies and fix example NFT
joshuahannan Aug 11, 2023
bc46319
fix import cadence issue and remove view
joshuahannan Aug 11, 2023
4387871
comment out default method conflicts
joshuahannan Aug 18, 2023
620416c
comment out usedUUID
joshuahannan Aug 18, 2023
523f9fa
comment out CollectionPublic
joshuahannan Aug 18, 2023
3945512
generate assets
joshuahannan Aug 18, 2023
f3c95ef
remove CollectionPublic from metadata views
joshuahannan Aug 18, 2023
719b931
add get length
joshuahannan Sep 6, 2023
ac62857
fixed missing auth for provider type
bjartek Sep 6, 2023
21640aa
Merge branch 'master' into standard-v2-updates
sisyphusSmiling Oct 20, 2023
1a261c0
update NFTForwarding for Cadence 1.0
sisyphusSmiling Oct 20, 2023
d9ef40e
update NFTForwarding transactions for new implementation
sisyphusSmiling Oct 20, 2023
2d9a34c
bump ci flow cli version to Cadence 1.0 pre-release
sisyphusSmiling Oct 23, 2023
8014190
fix ExampleNFT-v2 account storage access bug
sisyphusSmiling Oct 24, 2023
4311a6c
update FungibleToken Cadence 1.0 implementation
sisyphusSmiling Oct 24, 2023
262c73f
update flow.json with v2 contract implementations
sisyphusSmiling Oct 24, 2023
d872c31
update txns & scripts for Cadence 1.0 + supporting ExampleNFT-v2 Cade…
sisyphusSmiling Oct 24, 2023
c6330af
update Makefile & go tests
sisyphusSmiling Oct 24, 2023
ef9b4d7
update NFT-v2 to emit events from interface pre/post conditions
sisyphusSmiling Oct 24, 2023
359da96
update ExampleNFT-v2 Cadence tests & go assets
sisyphusSmiling Oct 24, 2023
0649cdf
update ExampleNFT-v2 providerPath
sisyphusSmiling Oct 24, 2023
b959c5b
update go tests and supporting txns
sisyphusSmiling Oct 24, 2023
92526d4
update go assets
sisyphusSmiling Oct 24, 2023
42b00b3
fix test cases to correspond with new contract implementations
sisyphusSmiling Oct 24, 2023
0f2bb28
add metadata trait test validation to go suite
sisyphusSmiling Oct 24, 2023
6958b19
update flow.json with emulator aliases
sisyphusSmiling Oct 24, 2023
cf9a423
fix NFTForwarding.Forwarder conformance to .Receiver & rename events
sisyphusSmiling Oct 24, 2023
c7aa593
add NFTForwarding Cadence tests & fix txn bugs
sisyphusSmiling Oct 24, 2023
cb3b555
complete NFTForwarding cadence tests + supporting txns & scripts
sisyphusSmiling Oct 24, 2023
f42de59
update .gitignore to include coverage.json
sisyphusSmiling Oct 24, 2023
88a73f1
fix contract.go placeholder variable name
sisyphusSmiling Oct 26, 2023
3c50d77
update NFT.transfer() pre-conditions on recevier.check() & .getIDs().…
sisyphusSmiling Nov 6, 2023
60eb711
update instances of Collection.getIDs().length with .getLength()
sisyphusSmiling Nov 6, 2023
8531ac6
add comments to test_helpers methods
sisyphusSmiling Nov 7, 2023
4347b53
update go assets
sisyphusSmiling Nov 7, 2023
86ca92b
re-add .transfer() pre-condition on .getIDs().contains(id)
sisyphusSmiling Nov 7, 2023
3f3d5a7
update go assets
sisyphusSmiling Nov 7, 2023
683df24
Merge pull request #194 from onflow/standard-v2-updates
sisyphusSmiling Nov 7, 2023
2b6dfd6
remove transfer, withdraw methods, and default implementations
joshuahannan Nov 14, 2023
825022e
add universal collection and other small changes
joshuahannan Nov 20, 2023
b11e79f
Merge remote-tracking branch 'origin/master' into standard-v2
joshuahannan Nov 20, 2023
7020df2
added updated event
bjartek Dec 1, 2023
408c68c
Update contracts/NonFungibleToken-v2.cdc
bjartek Dec 1, 2023
01c7114
add sub NFT, remove borrowNFTSafe
joshuahannan Dec 4, 2023
a3aebb3
Merge remote-tracking branch 'origin/standard-v2' into standard-v2
joshuahannan Dec 4, 2023
eb1dd95
change updated to use entitled reference
joshuahannan Dec 4, 2023
24d5952
remove custom destructors
joshuahannan Dec 12, 2023
456a980
remove resource destructor
turbolent Dec 13, 2023
ecf0b5b
generate
turbolent Dec 13, 2023
aebb56b
default destroy event, event args, id field, remove getID, go test up…
joshuahannan Jan 10, 2024
c0ff8f7
remove path functions, add view function, update view resolver names
joshuahannan Jan 11, 2024
30ef48a
add getIDs
joshuahannan Jan 11, 2024
2c9be03
remove view, add getIDs
joshuahannan Jan 12, 2024
b73ac84
add subNFTs method, update forwarder events
joshuahannan Jan 16, 2024
ded9217
add support for multiple type definitions
joshuahannan Jan 22, 2024
3c2b2d2
remove get NFT types, update basic NFT and UniversalCollection, and u…
joshuahannan Jan 22, 2024
bcf55c5
Update Cadence version
SupunS Jan 20, 2024
0a43997
add event emission functions
joshuahannan Jan 24, 2024
d896d25
revert event emission functions
joshuahannan Jan 24, 2024
4973179
update sdk and cadence deps
joshuahannan Jan 25, 2024
56b6daf
update to SDK v1.0.0-M1
turbolent Jan 25, 2024
2118663
update to SDK v1.0.0-M1
turbolent Jan 25, 2024
d2b571f
remove event functions, make update access contract, fix some tests
joshuahannan Jan 25, 2024
58c75f2
update transactions get get Go tests passing
joshuahannan Jan 31, 2024
fdeb8ee
sync with master
joshuahannan Jan 31, 2024
912407f
add collection public interface back and remove some go tests
joshuahannan Feb 1, 2024
ebdb001
use receiver and collection in public linked type
joshuahannan Feb 1, 2024
e8c999a
use correct public linked types and get most tests passing
joshuahannan Feb 5, 2024
322e5f5
add updated FT
joshuahannan Feb 5, 2024
86ee8c3
remove burner
joshuahannan Feb 5, 2024
e3b2202
add generic setup and transfer transactions
joshuahannan Feb 9, 2024
48f42d9
update generic transfer transactions and add tests
joshuahannan Feb 13, 2024
1bf01d6
change address arguments to strings
joshuahannan Feb 14, 2024
cd2c42e
use withhexprefix
joshuahannan Feb 14, 2024
938a91c
use latest import syntax update readme and use correct borrow syntax
joshuahannan Mar 5, 2024
9026973
update ci to use flow-c1
joshuahannan Mar 5, 2024
bd7ca70
add info about old branch to README
joshuahannan Mar 6, 2024
e135b94
update previewnet address
joshuahannan Mar 8, 2024
024d61f
update view resolver comments
joshuahannan Mar 11, 2024
3a595a3
remove basic NFT and UniversalCollection
joshuahannan Mar 11, 2024
058d82e
Make ExampleNFT compatible for contract update
SupunS Mar 21, 2024
d72353a
Add back the type assertion for the deposited token
SupunS Mar 22, 2024
c949828
Make the collection path backward compatible
SupunS Mar 25, 2024
e69a42c
remove docs, INFT, and update paths
joshuahannan Mar 26, 2024
c01c72c
make ci
joshuahannan Mar 26, 2024
1b8384e
Cleanup redundant paths
SupunS Mar 28, 2024
067c816
re-add royalties to mint and address PR comments
joshuahannan Apr 1, 2024
87ea0d0
fix FungibleToken import address
joshuahannan Apr 1, 2024
7cbc99e
add pre-conditions to createEmpty and update dependencies
joshuahannan Apr 2, 2024
74687e7
make emitNFTUpdated access all
joshuahannan Apr 2, 2024
808e6db
reorg transactions and scripts
joshuahannan Apr 3, 2024
f122847
fix import placeholders
joshuahannan Apr 9, 2024
cd08f8b
add correct getLength impl
joshuahannan Apr 10, 2024
17a6587
add NFT storage requirement and forEachID function
joshuahannan Apr 11, 2024
8d4f496
add def impl for getLength and fix iterator test
joshuahannan Apr 11, 2024
68c66a2
update iterate script and test access(all)
joshuahannan Apr 11, 2024
a0d5ecc
update comments
joshuahannan Apr 11, 2024
39036ac
use capabilities borrow
joshuahannan Apr 15, 2024
4a6f42d
make ownedNFTs access(all)
joshuahannan Apr 24, 2024
fa1f400
remove Owner entitlement
joshuahannan Apr 29, 2024
40c3de7
merge evm view from master
joshuahannan Apr 29, 2024
c640157
Update ExampleNFT v2 with EVMBridgedMetadata view from master (#215)
sisyphusSmiling May 2, 2024
c614396
resolve conflicts
joshuahannan May 2, 2024
f741cb5
update to latest CLI and emulator and fix txs and tests to not use op…
joshuahannan May 6, 2024
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.19'
go-version: '1.20'
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
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.5.0
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v1.9.2-stable-cadence.1
- name: Flow CLI Version
run: flow version
- name: Update PATH
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.vscode
node_modules
node_modules
coverage.json
130 changes: 130 additions & 0 deletions contracts/BasicNFT.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
*
* This is an basic implementation of a Flow Non-Fungible Token using the V2 standard.
* It shows that a basic NFT can be defined in very few lines of code (less than 100 here)
*
* Unlike the `ExampleNFT-v2` contract, this NFT illustrates a minimal implementation
* of an NFT that is now possible with the NFT standard since Events, collections,
* and other old requirements are not required any more.
*
* It also includes minimal metadata to showcase the simplicity
*
*/

import NonFungibleToken from "NonFungibleToken"
import MetadataViews from "MetadataViews"
import ViewResolver from "ViewResolver"
import UniversalCollection from "UniversalCollection"

access(all) contract BasicNFT: NonFungibleToken {

/// The only thing that an NFT really needs to have is this resource definition
access(all) resource NFT: NonFungibleToken.NFT {
/// Arbitrary trait mapping metadata
access(self) let metadata: {String: AnyStruct}

access(all) let id: UInt64

init(
metadata: {String: AnyStruct},
) {
self.id = self.uuid
self.metadata = metadata
}

access(all) fun createEmptyCollection(): @{NonFungibleToken.Collection} {
return <- BasicNFT.createEmptyCollection(nftType: self.getType())
}

/// Uses the basic NFT views
access(all) view fun getViews(): [Type] {
return [
Type<MetadataViews.Display>(),
Type<MetadataViews.Serial>(),
Type<MetadataViews.Traits>(),
Type<MetadataViews.NFTCollectionData>(),
Type<MetadataViews.NFTCollectionDisplay>()
]
}

access(all) fun resolveView(_ view: Type): AnyStruct? {
switch view {
case Type<MetadataViews.Display>():
return MetadataViews.Display(
name: self.metadata["name"] as! String,
description: self.metadata["description"] as! String,
thumbnail: MetadataViews.HTTPFile(
url: self.metadata["thumbnail"] as! String
)
)
case Type<MetadataViews.Serial>():
return MetadataViews.Serial(
self.id
)
case Type<MetadataViews.Traits>():
return MetadataViews.dictToTraits(dict: self.metadata, excludedNames: nil)
case Type<MetadataViews.NFTCollectionData>():
return BasicNFT.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>())
case Type<MetadataViews.NFTCollectionDisplay>():
return BasicNFT.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionDisplay>())
}
return nil
}
}

access(all) view fun getContractViews(resourceType: Type?): [Type] {
return [
Type<MetadataViews.NFTCollectionData>(),
Type<MetadataViews.NFTCollectionDisplay>()
]
}

access(all) fun resolveContractView(resourceType: Type?, viewType: Type): AnyStruct? {
switch viewType {
case Type<MetadataViews.NFTCollectionData>():
let collectionRef = self.account.storage.borrow<&ExampleNFT.Collection>(
from: /storage/cadenceExampleNFTCollection
) ?? panic("Could not borrow a reference to the stored collection")

return collectionRef.getNFTCollectionDataView()
case Type<MetadataViews.NFTCollectionDisplay>():
let media = MetadataViews.Media(
file: MetadataViews.HTTPFile(
url: "https://assets.website-files.com/5f6294c0c7a8cdd643b1c820/5f6294c0c7a8cda55cb1c936_Flow_Wordmark.svg"
),
mediaType: "image/svg+xml"
)
return MetadataViews.NFTCollectionDisplay(
name: "The Example Collection",
description: "This collection is used as an example to help you develop your next Flow NFT.",
externalURL: MetadataViews.ExternalURL("https://example-nft.onflow.org"),
squareImage: media,
bannerImage: media,
socials: {
"twitter": MetadataViews.ExternalURL("https://twitter.com/flow_blockchain")
}
)
}
return nil
}

access(all) resource NFTMinter {
access(all) fun mintNFT(metadata: {String: AnyStruct}): @BasicNFT.NFT {
return <- create NFT(metadata: metadata)
}
}

access(all) fun createEmptyCollection(nftType: Type): @{NonFungibleToken.Collection} {
return <- UniversalCollection.createEmptyCollection(identifier: "flowBasicNFTCollection", type: Type<@BasicNFT.NFT>())
}

init() {
let minter <- create NFTMinter()
self.account.storage.save(<-minter, to: /storage/flowBasicNFTMinterPath)

let collection <- self.createEmptyCollection(nftType: Type<@BasicNFT.NFT>()>)
let dataView = collection.getNFTCollectionDataView()
self.account.storage.save(collection, to: dataView.storagePath)
}
}

Loading
Loading