Skip to content

Commit 0e8d630

Browse files
authored
Merge pull request #160 from onflow/nialexsan/update-cadence
Nialexsan/update cadence
2 parents 5c7d8f4 + f897b7e commit 0e8d630

4 files changed

Lines changed: 158 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ jobs:
1010
EXAMPLENFT_TESTNET_HOLDER_ACCOUNT_PRIVATE_KEY: ${{ secrets.EXAMPLENFT_TESTNET_HOLDER_ACCOUNT_PRIVATE_KEY }}
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Checkout Repo
14+
uses: actions/checkout@v4
1315
- name: Install Node
14-
uses: actions/setup-node@v1
16+
uses: actions/setup-node@v4
1517
with:
16-
node-version: 16
18+
node-version: 18
1719

1820
# This should be switched to the regular CLI once the stable-cadence branch is merged
1921
- name: Install Cadence 1.0 Flow CLI
2022
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
2123

2224
- name: Update PATH
2325
run: echo "/root/.local/bin" >> $GITHUB_PATH
24-
25-
- name: Checkout Repo
26-
uses: actions/checkout@v2
26+
27+
- run: echo $(flow version)
2728

2829
- name: Install Dependencies
2930
run: npm install
@@ -35,6 +36,6 @@ jobs:
3536
if: always()
3637
run: npm test
3738

38-
- name: Run E2E Cypress Tests
39-
if: always()
40-
run: npm run e2e
39+
# - name: Run E2E Cypress Tests
40+
# if: always()
41+
# run: npm run e2e
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
{"transactions":{"link_views_collections":"import MetadataViews from 0xMetadataViews\n\ntransaction(collectionPublicPath: String, collectionStoragePath: String) {\n prepare(acct: AuthAccount) {\n pre {\n acct.borrow<&AnyResource>(from: StoragePath(identifier: collectionStoragePath)!) != nil: \"No Collection On Provided Storage Path.\"\n }\n let publicPath = PublicPath(identifier: collectionPublicPath)!\n let storagePath = StoragePath(identifier: collectionStoragePath)!\n if acct.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(publicPath).borrow() == nil {\n acct.link<&AnyResource{MetadataViews.ResolverCollection}>(publicPath, target: storagePath)\n }\n }\n\n execute {\n }\n}"},"scripts":{"check_for_links":"import MetadataViews from 0xMetadataViews\n\n/*\n Script to check for the implementation of all recommended MetadataViews.\n */\npub fun main(ownerAddress: Address, collectionPublicPath: String): {String: Bool} {\n let owner = getAccount(ownerAddress)\n return { \n \"MetadataViews\": owner.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(PublicPath(identifier: collectionPublicPath)!).check(),\n \"AnyResource\": owner.getCapability<&AnyResource>(PublicPath(identifier: collectionPublicPath)!).check()\n }\n}","check_for_recommended_v1_views":"import MetadataViews from 0xMetadataViews\nimport NFTRetrieval from 0xNFTRetrieval\n\n/*\n Script to check for the implementation of all recommended MetadataViews.\n */\npub fun main(ownerAddress: Address, collectionPublicPath: PublicPath): {String: Bool} {\n let owner = getAccount(ownerAddress)\n let collectionCap = owner.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(collectionPublicPath)\n assert(collectionCap.check(), message: \"MetadataViews Collection is not set up properly, ensure the Capability was created/linked correctly.\")\n let collection = collectionCap.borrow()!\n assert(collection.getIDs().length > 0, message: \"No NFTs exist in this collection, ensure the provided account has at least 1 NFTs.\")\n let testNftId = collection.getIDs()[0]\n let nftResolver = collection.borrowViewResolver(id: testNftId)\n let views: {String: Bool} = {}\n // Initialize map to all falses for recommended views.\n for view in NFTRetrieval.getRecommendedViewsTypes(version: \"v1\") {\n views.insert(key: view.identifier, false)\n }\n // Set to true if supported.\n for view in nftResolver.getViews() {\n if views.containsKey(view.identifier) {\n views.insert(key: view.identifier, true)\n }\n }\n return views\n}","get_current_views":"import MetadataViews from 0xMetadataViews\n\n/*\n Script to check all currently implemented MetadataViews.\n In addition, it will ensure if the Public Collection is setup and linked correctly for consumption.\n Returns all View Types.\n */\npub fun main(ownerAddress: Address, collectionPublicPath: PublicPath): [Type] {\n let owner = getAccount(ownerAddress)\n let collectionCap = owner.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(collectionPublicPath)\n assert(collectionCap.check(), message: \"MetadataViews Collection is not set up properly, ensure the Capability was created/linked correctly.\")\n let collection = collectionCap.borrow()!\n assert(collection.getIDs().length > 0, message: \"No NFTs exist in this collection, ensure the provided account has at least 1 NFTs.\")\n let testNftId = collection.getIDs()[0]\n let nftResolver = collection.borrowViewResolver(id: testNftId)\n return nftResolver.getViews()\n}","get_recommended_v1_views":"import MetadataViews from 0xMetadataViews\nimport NFTRetrieval from 0xNFTRetrieval\n\n/*\n Script to get all currently recommended MetadataViews.\n */\npub fun main(): [Type] {\n return NFTRetrieval.getRecommendedViewsTypes(version: \"v1\")\n}"},"vars":{"emulator":{"0xMetadataViews":null,"0xNFTCatalog":null,"0xNFTRetrieval":null},"testnet":{"0xMetadataViews":"0x631e88ae7f1d7c20","0xNFTCatalog":"0x324c34e1c517e4db","0xNFTRetrieval":"0x324c34e1c517e4db"},"mainnet":{"0xMetadataViews":"0x1d7e57aa55817448","0xNFTCatalog":"0x49a7cda3a1eecc29","0xNFTRetrieval":"0x49a7cda3a1eecc29"}}}
1+
{
2+
"transactions": {
3+
"link_views_collections": "import MetadataViews from 0xMetadataViews\n\ntransaction(collectionPublicPath: String, collectionStoragePath: String) {\n prepare(acct: AuthAccount) {\n pre {\n acct.borrow<&AnyResource>(from: StoragePath(identifier: collectionStoragePath)!) != nil: \"No Collection On Provided Storage Path.\"\n }\n let publicPath = PublicPath(identifier: collectionPublicPath)!\n let storagePath = StoragePath(identifier: collectionStoragePath)!\n if acct.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(publicPath).borrow() == nil {\n acct.link<&AnyResource{MetadataViews.ResolverCollection}>(publicPath, target: storagePath)\n }\n }\n\n execute {\n }\n}"
4+
},
5+
"scripts": {
6+
"check_for_links": "import MetadataViews from 0xMetadataViews\n\n/*\n Script to check for the implementation of all recommended MetadataViews.\n */\naccess(all) fun main(ownerAddress: Address, collectionPublicPath: String): {String: Bool} {\n let owner = getAccount(ownerAddress)\n return { \n \"MetadataViews\": owner.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(PublicPath(identifier: collectionPublicPath)!).check(),\n \"AnyResource\": owner.getCapability<&AnyResource>(PublicPath(identifier: collectionPublicPath)!).check()\n }\n}",
7+
"check_for_recommended_v1_views": "import MetadataViews from 0xMetadataViews\nimport NFTRetrieval from 0xNFTRetrieval\n\n/*\n Script to check for the implementation of all recommended MetadataViews.\n */\naccess(all) fun main(ownerAddress: Address, collectionPublicPath: PublicPath): {String: Bool} {\n let owner = getAccount(ownerAddress)\n let collectionCap = owner.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(collectionPublicPath)\n assert(collectionCap.check(), message: \"MetadataViews Collection is not set up properly, ensure the Capability was created/linked correctly.\")\n let collection = collectionCap.borrow()!\n assert(collection.getIDs().length > 0, message: \"No NFTs exist in this collection, ensure the provided account has at least 1 NFTs.\")\n let testNftId = collection.getIDs()[0]\n let nftResolver = collection.borrowViewResolver(id: testNftId)\n let views: {String: Bool} = {}\n // Initialize map to all falses for recommended views.\n for view in NFTRetrieval.getRecommendedViewsTypes(version: \"v1\") {\n views.insert(key: view.identifier, false)\n }\n // Set to true if supported.\n for view in nftResolver.getViews() {\n if views.containsKey(view.identifier) {\n views.insert(key: view.identifier, true)\n }\n }\n return views\n}",
8+
"get_current_views": "import MetadataViews from 0xMetadataViews\n\n/*\n Script to check all currently implemented MetadataViews.\n In addition, it will ensure if the Public Collection is setup and linked correctly for consumption.\n Returns all View Types.\n */\naccess(all) fun main(ownerAddress: Address, collectionPublicPath: PublicPath): [Type] {\n let owner = getAccount(ownerAddress)\n let collectionCap = owner.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(collectionPublicPath)\n assert(collectionCap.check(), message: \"MetadataViews Collection is not set up properly, ensure the Capability was created/linked correctly.\")\n let collection = collectionCap.borrow()!\n assert(collection.getIDs().length > 0, message: \"No NFTs exist in this collection, ensure the provided account has at least 1 NFTs.\")\n let testNftId = collection.getIDs()[0]\n let nftResolver = collection.borrowViewResolver(id: testNftId)\n return nftResolver.getViews()\n}",
9+
"get_recommended_v1_views": "import MetadataViews from 0xMetadataViews\nimport NFTRetrieval from 0xNFTRetrieval\n\n/*\n Script to get all currently recommended MetadataViews.\n */\naccess(all) fun main(): [Type] {\n return NFTRetrieval.getRecommendedViewsTypes(version: \"v1\")\n}"
10+
},
11+
"vars": {
12+
"emulator": {
13+
"0xMetadataViews": null,
14+
"0xNFTCatalog": null,
15+
"0xNFTRetrieval": null
16+
},
17+
"testnet": {
18+
"0xMetadataViews": "0x631e88ae7f1d7c20",
19+
"0xNFTCatalog": "0x324c34e1c517e4db",
20+
"0xNFTRetrieval": "0x324c34e1c517e4db"
21+
},
22+
"mainnet": {
23+
"0xMetadataViews": "0x1d7e57aa55817448",
24+
"0xNFTCatalog": "0x49a7cda3a1eecc29",
25+
"0xNFTRetrieval": "0x49a7cda3a1eecc29"
26+
}
27+
}
28+
}

ui/apps/nft-portal/src/flow/catalog_c2j.json

Lines changed: 116 additions & 1 deletion
Large diffs are not rendered by default.

ui/apps/nft-portal/src/flow/utils.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@ export async function retrieveContractInformation(
5252
cadence: `
5353
import NonFungibleToken from ${fcl.withPrefix(nftStandardAddress)}
5454
import MetadataViews from ${fcl.withPrefix(nftStandardAddress)}
55+
import ViewResolver from ${fcl.withPrefix(nftStandardAddress)}
5556
import ${name} from ${fcl.withPrefix(address)}
5657
57-
pub fun main(): {String: AnyStruct} {
58+
access(all) fun main(): {String: AnyStruct} {
5859
var isNFTContract = false
5960
var collectionConformsToMetadata = false
6061
var nftConformsToMetadata = false
6162
62-
isNFTContract = Type<${name}>().isSubtype(of: Type<NonFungibleToken>())
63+
isNFTContract = Type<${name}>().isSubtype(of: Type<{NonFungibleToken}>())
6364
if (isNFTContract == true) {
64-
collectionConformsToMetadata = Type<&${name}.Collection>().isSubtype(of: Type<&{MetadataViews.ResolverCollection}>())
65-
nftConformsToMetadata = Type<&${name}.NFT>().isSubtype(of: Type<&{MetadataViews.Resolver}>())
65+
collectionConformsToMetadata = Type<&${name}.Collection>().isSubtype(of: Type<&{ViewResolver.ResolverCollection}>())
66+
nftConformsToMetadata = Type<&${name}.NFT>().isSubtype(of: Type<&{ViewResolver.Resolver}>())
6667
}
6768
6869
return {

0 commit comments

Comments
 (0)