Skip to content

Commit

Permalink
add getLength; improve flow.json
Browse files Browse the repository at this point in the history
  • Loading branch information
avcdsld committed Jul 30, 2024
1 parent 7736f92 commit acf35c4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
5 changes: 5 additions & 0 deletions packages/contracts/flow/contracts/SakutaroPoem.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ access(all) contract SakutaroPoem: NonFungibleToken {
access(all) resource interface SakutaroPoemCollectionPublic {
access(all) fun deposit(token: @{NonFungibleToken.NFT})
access(all) view fun getIDs(): [UInt64]
access(all) view fun getLength(): Int
access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}?
access(all) view fun borrowPoem(_ id: UInt64): &SakutaroPoem.NFT? {
post {
Expand Down Expand Up @@ -164,6 +165,10 @@ access(all) contract SakutaroPoem: NonFungibleToken {
return self.ownedNFTs.keys
}

access(all) view fun getLength(): Int {
return self.ownedNFTs.length
}

access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}? {
return &self.ownedNFTs[id] as &{NonFungibleToken.NFT}?
}
Expand Down
5 changes: 5 additions & 0 deletions packages/contracts/flow/contracts/SakutaroPoemReplica.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ access(all) contract SakutaroPoemReplica: NonFungibleToken {
access(all) resource interface SakutaroPoemReplicaCollectionPublic {
access(all) fun deposit(token: @{NonFungibleToken.NFT})
access(all) view fun getIDs(): [UInt64]
access(all) view fun getLength(): Int
access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}?
access(all) view fun borrowPoem(_ id: UInt64): &SakutaroPoemReplica.NFT? {
post {
Expand Down Expand Up @@ -113,6 +114,10 @@ access(all) contract SakutaroPoemReplica: NonFungibleToken {
return self.ownedNFTs.keys
}

access(all) view fun getLength(): Int {
return self.ownedNFTs.length
}

access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}? {
return &self.ownedNFTs[id] as &{NonFungibleToken.NFT}?
}
Expand Down
37 changes: 25 additions & 12 deletions packages/contracts/flow/flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,30 @@
}
},
"contracts": {
"NonFungibleToken": "./contracts/core/NonFungibleToken.cdc",
"ViewResolver": "./contracts/core/ViewResolver.cdc",
"MetadataViews": "./contracts/core/MetadataViews.cdc",
"NonFungibleToken": {
"source": "./contracts/core/NonFungibleToken.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"ViewResolver": {
"source": "./contracts/core/ViewResolver.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"MetadataViews": {
"source": "./contracts/core/MetadataViews.cdc",
"aliases": {
"emulator": "f8d6e0586b0a20c7",
"mainnet": "1d7e57aa55817448",
"testnet": "631e88ae7f1d7c20"
}
},
"Base64Util": "./contracts/Base64Util.cdc",
"SakutaroPoem": "./contracts/SakutaroPoem.cdc",
"SakutaroPoemReplica": "./contracts/SakutaroPoemReplica.cdc",
Expand Down Expand Up @@ -55,15 +76,7 @@
},
"deployments": {
"emulator": {
"emulator-account": [
"NonFungibleToken",
"ViewResolver",
"MetadataViews",
"Base64Util",
"SakutaroPoem",
"SakutaroPoemReplica",
"SakutaroPoemContent"
]
"emulator-account": ["Base64Util", "SakutaroPoem", "SakutaroPoemReplica", "SakutaroPoemContent"]
},
"testnet": {
"testnet-account": ["Base64Util", "SakutaroPoem", "SakutaroPoemReplica", "SakutaroPoemContent"]
Expand Down

0 comments on commit acf35c4

Please sign in to comment.