From a18ab8ac9ea297823b134031984e12f29298d337 Mon Sep 17 00:00:00 2001 From: "BT.Wood(Tang Bo Hao)" Date: Fri, 16 Aug 2024 16:39:07 +0800 Subject: [PATCH] feat: Upgrade Cadence1.0 (#18) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix data:image/ handling in metadata views image source helper (#16) * feat: update cadence contracts * feat: upgrade bug_hunter.js * feat: upgrade c1.0 * feat: dynamic load flow.json --------- Co-authored-by: Bastian Müller --- .gitignore | 4 +- .vscode/settings.json | 3 + cadence/contracts/FlowviewAccountBookmark.cdc | 62 +++-- cadence/scripts/get_bookmark.cdc | 7 +- cadence/scripts/get_bookmarks.cdc | 7 +- cadence/transactions/add_bookmark.cdc | 17 +- cadence/transactions/edit_bookmark.cdc | 17 +- cadence/transactions/remove_bookmark.cdc | 17 +- flow.json | 1 + flow/bug_hunter.js | 70 +++-- flow/config.js | 150 ++++++----- lib/utils.js | 4 +- public/flow.json | 244 ++++++++++++++++++ public/scripts/basic/get_account_info.cdc | 20 +- .../scripts/bookmark/account/get_bookmark.cdc | 8 +- .../bookmark/account/get_bookmarks.cdc | 8 +- .../collection/get_catalog_type_data.cdc | 2 +- .../get_nft_catalog_by_collection_ids.cdc | 2 +- .../scripts/collection/get_nft_displays.cdc | 20 +- .../collection/get_nft_displays_emulator.cdc | 21 +- .../collection/get_nft_metadata_views.cdc | 18 +- .../get_nft_metadata_views_emulator.cdc | 18 +- .../scripts/contract/get_contract_names.cdc | 9 +- .../scripts/domain/get_address_of_domain.cdc | 2 +- .../domain/get_default_domains_of_address.cdc | 2 +- public/scripts/hc/get_hc_manager_info.cdc | 38 +-- public/scripts/hc/get_owned_account_info.cdc | 40 +-- public/scripts/staking/get_delegator_info.cdc | 2 +- public/scripts/staking/get_epoch_metadata.cdc | 2 +- public/scripts/staking/get_node_info.cdc | 2 +- public/scripts/staking/get_staking_info.cdc | 80 +++--- .../storage/get_basic_public_items.cdc | 20 +- public/scripts/storage/get_private_items.cdc | 53 ++-- public/scripts/storage/get_private_paths.cdc | 23 +- public/scripts/storage/get_public_item.cdc | 26 +- public/scripts/storage/get_public_items.cdc | 46 ++-- public/scripts/storage/get_public_paths.cdc | 6 +- public/scripts/storage/get_storage_paths.cdc | 6 +- public/scripts/storage/get_stored_items.cdc | 82 +++--- .../scripts/storage/get_stored_resource.cdc | 6 +- public/scripts/storage/get_stored_struct.cdc | 6 +- .../storefront/get_existing_listings.cdc | 14 +- public/scripts/storefront/get_listings.cdc | 46 ++-- .../scripts/switchboard/get_switchboard.cdc | 25 +- .../bookmark/account/add_or_edit_bookmark.cdc | 19 +- .../bookmark/account/remove_bookmark.cdc | 19 +- .../collection/bulk_transfer_nft.cdc | 12 +- .../transactions/collection/transfer_nft.cdc | 10 +- public/transactions/hc/accept_ownership.cdc | 39 ++- public/transactions/hc/publish_to_parent.cdc | 17 +- public/transactions/hc/redeem_account.cdc | 40 ++- .../transactions/hc/remove_child_account.cdc | 8 +- .../hc/remove_parent_from_child.cdc | 8 +- .../hc/set_manager_capability_filter.cdc | 10 +- .../transactions/hc/setup_child_display.cdc | 8 +- public/transactions/hc/setup_hc_manager.cdc | 30 ++- .../transactions/hc/setup_owned_account.cdc | 33 +-- ...up_owned_account_and_publish_to_parent.cdc | 59 ++--- public/transactions/hc/transfer_ownership.cdc | 6 +- .../hc/transfer_ownership_from_manager.cdc | 6 +- public/transactions/key/create_key.cdc | 2 +- public/transactions/key/revoke_key.cdc | 2 +- public/transactions/storage/destroy.cdc | 8 +- public/transactions/storage/unlink.cdc | 4 +- public/transactions/storefront/buy_item.cdc | 2 +- .../storefront/cleanup_expired.cdc | 2 +- .../storefront/cleanup_ghosted.cdc | 2 +- .../storefront/cleanup_purchased.cdc | 2 +- .../transactions/storefront/remove_item.cdc | 2 +- public/transactions/storefront/sell_item.cdc | 2 +- .../transactions/storefront/setup_account.cdc | 2 +- .../switchboard/add_new_vault.cdc | 12 +- .../transactions/switchboard/remove_vault.cdc | 12 +- public/transactions/switchboard/setup.cdc | 23 +- 74 files changed, 992 insertions(+), 665 deletions(-) create mode 100644 .vscode/settings.json create mode 120000 flow.json create mode 100644 public/flow.json diff --git a/.gitignore b/.gitignore index d534f17..1ce79e3 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ next-env.d.ts *.private.json -*.bak \ No newline at end of file +*.bak + +imports \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d58225d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cadence.flowCommand": "flow-c1" +} diff --git a/cadence/contracts/FlowviewAccountBookmark.cdc b/cadence/contracts/FlowviewAccountBookmark.cdc index bcb93f6..9ea2b14 100644 --- a/cadence/contracts/FlowviewAccountBookmark.cdc +++ b/cadence/contracts/FlowviewAccountBookmark.cdc @@ -1,46 +1,48 @@ -pub contract FlowviewAccountBookmark { +access(all) contract FlowviewAccountBookmark { - pub let AccountBookmarkCollectionStoragePath: StoragePath - pub let AccountBookmarkCollectionPublicPath: PublicPath - pub let AccountBookmarkCollectionPrivatePath: PrivatePath + access(all) entitlement Manage - pub event AccountBookmarkAdded(owner: Address, address: Address, note: String) - pub event AccountBookmarkRemoved(owner: Address, address: Address) + access(all) let AccountBookmarkCollectionStoragePath: StoragePath + access(all) let AccountBookmarkCollectionPublicPath: PublicPath + access(all) let AccountBookmarkCollectionPrivatePath: PrivatePath - pub event ContractInitialized() + access(all) event AccountBookmarkAdded(owner: Address, address: Address, note: String) + access(all) event AccountBookmarkRemoved(owner: Address, address: Address) - pub resource interface AccountBookmarkPublic { - pub let address: Address - pub var note: String + access(all) event ContractInitialized() + + access(all) resource interface AccountBookmarkPublic { + access(all) let address: Address + access(all) var note: String } - pub resource AccountBookmark: AccountBookmarkPublic { - pub let address: Address - pub var note: String + access(all) resource AccountBookmark: AccountBookmarkPublic { + access(all) let address: Address + access(all) var note: String init(address: Address, note: String) { self.address = address self.note = note } - pub fun setNote(note: String) { + access(Manage) fun setNote(note: String) { self.note = note } } - pub resource interface CollectionPublic { - pub fun borrowPublicAccountBookmark(address: Address): &AccountBookmark{AccountBookmarkPublic}? - pub fun getAccountBookmarks(): &{Address: AccountBookmark{AccountBookmarkPublic}} + access(all) resource interface CollectionPublic { + access(all) view fun borrowPublicAccountBookmark(address: Address): &AccountBookmark? + access(all) view fun getAccountBookmarks(): &{Address: AccountBookmark} } - pub resource AccountBookmarkCollection: CollectionPublic { - pub let bookmarks: @{Address: AccountBookmark} + access(all) resource AccountBookmarkCollection: CollectionPublic { + access(all) let bookmarks: @{Address: AccountBookmark} init() { self.bookmarks <- {} } - pub fun addAccountBookmark(address: Address, note: String) { + access(Manage) fun addAccountBookmark(address: Address, note: String) { pre { self.bookmarks[address] == nil: "Account bookmark already exists" } @@ -48,29 +50,25 @@ pub contract FlowviewAccountBookmark { emit AccountBookmarkAdded(owner: self.owner!.address, address: address, note: note) } - pub fun removeAccountBookmark(address: Address) { + access(Manage) fun removeAccountBookmark(address: Address) { destroy self.bookmarks.remove(key: address) emit AccountBookmarkRemoved(owner: self.owner!.address, address: address) } - pub fun borrowPublicAccountBookmark(address: Address): &AccountBookmark{AccountBookmarkPublic}? { - return &self.bookmarks[address] as &AccountBookmark{AccountBookmarkPublic}? - } - - pub fun borrowAccountBookmark(address: Address): &AccountBookmark? { - return &self.bookmarks[address] as &AccountBookmark? + access(all) view fun borrowPublicAccountBookmark(address: Address): &AccountBookmark? { + return &self.bookmarks[address] } - pub fun getAccountBookmarks(): &{Address: AccountBookmark{AccountBookmarkPublic}} { - return &self.bookmarks as &{Address: AccountBookmark{AccountBookmarkPublic}} + access(Manage) fun borrowAccountBookmark(address: Address): auth(Manage) &AccountBookmark? { + return &self.bookmarks[address] } - destroy() { - destroy self.bookmarks + access(all) view fun getAccountBookmarks(): &{Address: AccountBookmark} { + return &self.bookmarks } } - pub fun createEmptyCollection(): @AccountBookmarkCollection { + access(all) fun createEmptyCollection(): @AccountBookmarkCollection { return <-create AccountBookmarkCollection() } diff --git a/cadence/scripts/get_bookmark.cdc b/cadence/scripts/get_bookmark.cdc index 81d116e..e2f723a 100644 --- a/cadence/scripts/get_bookmark.cdc +++ b/cadence/scripts/get_bookmark.cdc @@ -1,8 +1,9 @@ import FlowviewAccountBookmark from "../contracts/FlowviewAccountBookmark.cdc" -pub fun main(owner: Address, address: Address): &FlowviewAccountBookmark.AccountBookmark{FlowviewAccountBookmark.AccountBookmarkPublic}? { - let acct = getAuthAccount(owner) - let collection = acct.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) +access(all) fun main(owner: Address, address: Address): &FlowviewAccountBookmark.AccountBookmark? { + let acct = getAuthAccount(owner) + let collection = acct.storage + .borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow AccountBookmarkCollection") return collection.borrowPublicAccountBookmark(address: address) diff --git a/cadence/scripts/get_bookmarks.cdc b/cadence/scripts/get_bookmarks.cdc index baa5727..b7de588 100644 --- a/cadence/scripts/get_bookmarks.cdc +++ b/cadence/scripts/get_bookmarks.cdc @@ -1,8 +1,9 @@ import FlowviewAccountBookmark from "../contracts/FlowviewAccountBookmark.cdc" -pub fun main(owner: Address): &{Address: FlowviewAccountBookmark.AccountBookmark{FlowviewAccountBookmark.AccountBookmarkPublic}} { - let acct = getAuthAccount(owner) - let collection = acct.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) +access(all) fun main(owner: Address): &{Address: FlowviewAccountBookmark.AccountBookmark} { + let acct = getAuthAccount(owner) + let collection = acct.storage + .borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow AccountBookmarkCollection") return collection.getAccountBookmarks() diff --git a/cadence/transactions/add_bookmark.cdc b/cadence/transactions/add_bookmark.cdc index 8a30b44..36849ce 100644 --- a/cadence/transactions/add_bookmark.cdc +++ b/cadence/transactions/add_bookmark.cdc @@ -4,20 +4,19 @@ transaction( address: Address, note: String ) { - let bookmarkCollection: &FlowviewAccountBookmark.AccountBookmarkCollection + let bookmarkCollection: auth(FlowviewAccountBookmark.Manage) &FlowviewAccountBookmark.AccountBookmarkCollection - prepare(signer: AuthAccount) { - if signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { + prepare(signer: auth(Storage, Capabilities) &Account) { + if signer.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { let collection <- FlowviewAccountBookmark.createEmptyCollection() - signer.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.storage.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) - let cap = signer.link<&FlowviewAccountBookmark.AccountBookmarkCollection{FlowviewAccountBookmark.CollectionPublic}>( - FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath, - target: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath - ) ?? panic("Could not create public capability") + let cap = signer.capabilities.storage.issue<&FlowviewAccountBookmark.AccountBookmarkCollection>(FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.capabilities.publish(cap, at: FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath) } - self.bookmarkCollection = signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + self.bookmarkCollection = signer.storage + .borrow(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow collection") } diff --git a/cadence/transactions/edit_bookmark.cdc b/cadence/transactions/edit_bookmark.cdc index 4ba0fa6..34f269e 100644 --- a/cadence/transactions/edit_bookmark.cdc +++ b/cadence/transactions/edit_bookmark.cdc @@ -4,20 +4,19 @@ transaction( address: Address, note: String ) { - let bookmarkCollection: &FlowviewAccountBookmark.AccountBookmarkCollection + let bookmarkCollection: auth(FlowviewAccountBookmark.Manage) &FlowviewAccountBookmark.AccountBookmarkCollection - prepare(signer: AuthAccount) { - if signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { + prepare(signer: auth(Storage, Capabilities) &Account) { + if signer.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { let collection <- FlowviewAccountBookmark.createEmptyCollection() - signer.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.storage.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) - let cap = signer.link<&FlowviewAccountBookmark.AccountBookmarkCollection{FlowviewAccountBookmark.CollectionPublic}>( - FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath, - target: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath - ) ?? panic("Could not create public capability") + let cap = signer.capabilities.storage.issue<&FlowviewAccountBookmark.AccountBookmarkCollection>(FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.capabilities.publish(cap, at: FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath) } - self.bookmarkCollection = signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + self.bookmarkCollection = signer.storage + .borrow(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow collection") } diff --git a/cadence/transactions/remove_bookmark.cdc b/cadence/transactions/remove_bookmark.cdc index f0b6c2c..01331d7 100644 --- a/cadence/transactions/remove_bookmark.cdc +++ b/cadence/transactions/remove_bookmark.cdc @@ -1,20 +1,19 @@ import FlowviewAccountBookmark from "../contracts/FlowviewAccountBookmark.cdc" transaction(address: Address) { - let bookmarkCollection: &FlowviewAccountBookmark.AccountBookmarkCollection + let bookmarkCollection: auth(FlowviewAccountBookmark.Manage) &FlowviewAccountBookmark.AccountBookmarkCollection - prepare(signer: AuthAccount) { - if signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { + prepare(signer: auth(Storage, Capabilities) &Account) { + if signer.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { let collection <- FlowviewAccountBookmark.createEmptyCollection() - signer.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.storage.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) - let cap = signer.link<&FlowviewAccountBookmark.AccountBookmarkCollection{FlowviewAccountBookmark.CollectionPublic}>( - FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath, - target: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath - ) ?? panic("Could not create public capability") + let cap = signer.capabilities.storage.issue<&FlowviewAccountBookmark.AccountBookmarkCollection>(FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.capabilities.publish(cap, at: FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath) } - self.bookmarkCollection = signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + self.bookmarkCollection = signer.storage + .borrow(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow collection") } diff --git a/flow.json b/flow.json new file mode 120000 index 0000000..091fc18 --- /dev/null +++ b/flow.json @@ -0,0 +1 @@ +public/flow.json \ No newline at end of file diff --git a/flow/bug_hunter.js b/flow/bug_hunter.js index ee95201..4067d0c 100644 --- a/flow/bug_hunter.js +++ b/flow/bug_hunter.js @@ -4,8 +4,8 @@ import { getPublicPaths } from "./scripts" export const getStoragePaths = async (address) => { const code = ` - pub fun main(address: Address): [String] { - let account = getAuthAccount(address) + access(all) fun main(address: Address): [String] { + let account = getAuthAccount(address) let paths: [String] = [] account.forEachStored(fun (path: StoragePath, type: Type): Bool { paths.append(path.toString()) @@ -13,22 +13,20 @@ export const getStoragePaths = async (address) => { }) return paths } - ` + `; const paths = await fcl.query({ cadence: code, - args: (arg, t) => [ - arg(address, t.Address), - ] - }) + args: (arg, t) => [arg(address, t.Address)], + }); - return paths -} + return paths; +}; export const getPrivatePaths = async (address) => { const code = ` - pub fun main(address: Address): [String] { - let account = getAuthAccount(address) + access(all) fun main(address: Address): [String] { + let account = getAuthAccount(address) let paths: [String] = [] account.forEachPrivate(fun (path: PrivatePath, type: Type): Bool { paths.append(path.toString()) @@ -36,24 +34,22 @@ export const getPrivatePaths = async (address) => { }) return paths } - ` + `; const paths = await fcl.query({ cadence: code, - args: (arg, t) => [ - arg(address, t.Address), - ] - }) + args: (arg, t) => [arg(address, t.Address)], + }); - return paths -} + return paths; +}; export const getTypeOfPrivatePath = async (address, path) => { - const pathIdentifier = path.replace("/private/", "") + const pathIdentifier = path.replace("/private/", ""); const code = ` - pub fun main(address: Address, pathIdentifier: String): String? { - let account = getAuthAccount(address) + access(all) fun main(address: Address, pathIdentifier: String): String? { + let account = getAuthAccount(address) let path: PrivatePath = PrivatePath(identifier: pathIdentifier)! let target = account.getLinkTarget(path) var targetPath: String? = nil @@ -62,40 +58,34 @@ export const getTypeOfPrivatePath = async (address, path) => { } return targetPath } - ` + `; const type = await fcl.query({ cadence: code, - args: (arg, t) => [ - arg(address, t.Address), - arg(pathIdentifier, t.String) - ] - }) + args: (arg, t) => [arg(address, t.Address), arg(pathIdentifier, t.String)], + }); - return type -} + return type; +}; export const getTypeOfStoragePath = async (address, path) => { - const pathIdentifier = path.replace("/storage/", "") + const pathIdentifier = path.replace("/storage/", ""); const code = ` - pub fun main(address: Address, pathIdentifier: String): Type? { - let account = getAuthAccount(address) + access(all) fun main(address: Address, pathIdentifier: String): Type? { + let account = getAuthAccount(address) let path: StoragePath = StoragePath(identifier: pathIdentifier)! return account.type(at: path) } - ` + `; const type = await fcl.query({ cadence: code, - args: (arg, t) => [ - arg(address, t.Address), - arg(pathIdentifier, t.String) - ] - }) + args: (arg, t) => [arg(address, t.Address), arg(pathIdentifier, t.String)], + }); - return type -} + return type; +}; // export const hunt2 = async (address) => { // const paths = await getStoragePaths(address) diff --git a/flow/config.js b/flow/config.js index 4fc14e8..7fb2574 100644 --- a/flow/config.js +++ b/flow/config.js @@ -2,74 +2,86 @@ import { config } from "@onflow/fcl" import publicConfig from "../publicConfig" import { send as httpSend } from "@onflow/transport-http" -console.log(publicConfig.chainEnv) +async function main() { + console.log(publicConfig.chainEnv); -if (publicConfig.chainEnv == "emulator") { - config({ - "flow.network": "local", - "accessNode.api": "http://localhost:8888", - "discovery.wallet": "http://localhost:8701/fcl/authn", - "sdk.transport": httpSend, - "app.detail.title": "flowview", - "app.detail.icon": "https://i.imgur.com/YL8MLEd.png", + let cfg; + if (publicConfig.chainEnv == "emulator") { + cfg = config({ + "flow.network": "local", + "accessNode.api": "http://localhost:8888", + "discovery.wallet": "http://localhost:8701/fcl/authn", + "sdk.transport": httpSend, + "app.detail.title": "flowview", + "app.detail.icon": "https://i.imgur.com/YL8MLEd.png", - "0xFlowToken": "0xf8d6e0586b0a20c7", - "0xNFTCatalog": "0xf8d6e0586b0a20c7", - "0xMetadataViews": "0xf8d6e0586b0a20c7", - "0xNonFungibleToken": "0xf8d6e0586b0a20c7", - "0xFungibleToken": "0xee82856bf20e2aa6", - "0xFungibleTokenSwitchboard": "0xee82856bf20e2aa6" - }) -} else if (publicConfig.chainEnv == "testnet") { - config({ - "flow.network": "testnet", - "accessNode.api": "https://side-still-sanctuary.flow-testnet.quiknode.pro", - "discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn", - "sdk.transport": httpSend, - "app.detail.title": "flowview", - "app.detail.icon": "https://i.imgur.com/YL8MLEd.png", - - "0xFlowToken": "0x7e60df042a9c0868", - "0xNFTCatalog": "0x324c34e1c517e4db", - "0xMetadataViews": "0x631e88ae7f1d7c20", - "0xNonFungibleToken": "0x631e88ae7f1d7c20", - "0xFungibleToken": "0x9a0766d93b6608b7", - "0xFungibleTokenSwitchboard": "0x9a0766d93b6608b7", - "0xFlowbox": "0xbca26f5091cd39ec", - "0xFlowviewAccountBookmark": "0xdc34f5a7b807bcfb", - "0xNFTStorefrontV2": "0x2d55b98eb200daef", - - "0xHybridCustody": "0x294e44e1ec6993c6", - "0xCapabilityFactory": "0x294e44e1ec6993c6", - "0xCapabilityFilter": "0x294e44e1ec6993c6", - "0xCapabilityDelegator": "0x294e44e1ec6993c6", - "0xFindViews": "0x35717efbbce11c74", - "0xFlowmap": "0x72ed11a540a52efc" - }) -} else { - config({ - "flow.network": "mainnet", - "accessNode.api": "https://floral-special-valley.flow-mainnet.quiknode.pro", - "discovery.wallet": "https://fcl-discovery.onflow.org/authn", - "sdk.transport": httpSend, - "app.detail.title": "flowview", - "app.detail.icon": "https://i.imgur.com/YL8MLEd.png", - - "0xFlowToken": "0x1654653399040a61", - "0xNFTCatalog": "0x49a7cda3a1eecc29", - "0xMetadataViews": "0x1d7e57aa55817448", - "0xNonFungibleToken": "0x1d7e57aa55817448", - "0xFungibleToken": "0xf233dcee88fe0abe", - "0xFungibleTokenSwitchboard": "0xf233dcee88fe0abe", - "0xFlowbox": "0x1b3930856571a52b", - "0xFlowviewAccountBookmark": "0x39b144ab4d348e2b", - "0xNFTStorefrontV2": "0x4eb8a10cb9f87357", - - "0xHybridCustody": "0xd8a7e05a7ac670c0", - "0xCapabilityFactory": "0xd8a7e05a7ac670c0", - "0xCapabilityFilter": "0xd8a7e05a7ac670c0", - "0xCapabilityDelegator": "0xd8a7e05a7ac670c0", - "0xFindViews": "0x097bafa4e0b48eef", - "0xFlowmap": "0x483f0fe77f0d59fb" - }) -} \ No newline at end of file + "0xFlowToken": "0xf8d6e0586b0a20c7", + "0xNFTCatalog": "0xf8d6e0586b0a20c7", + "0xMetadataViews": "0xf8d6e0586b0a20c7", + "0xViewResolver": "0xf8d6e0586b0a20c7", + "0xNonFungibleToken": "0xf8d6e0586b0a20c7", + "0xFungibleToken": "0xee82856bf20e2aa6", + "0xFungibleTokenSwitchboard": "0xee82856bf20e2aa6", + }); + } else if (publicConfig.chainEnv == "testnet") { + cfg = config({ + "flow.network": "testnet", + "accessNode.api": + "https://side-still-sanctuary.flow-testnet.quiknode.pro", + "discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn", + "sdk.transport": httpSend, + "app.detail.title": "flowview", + "app.detail.icon": "https://i.imgur.com/YL8MLEd.png", + + "0xFlowToken": "0x7e60df042a9c0868", + "0xNFTCatalog": "0x324c34e1c517e4db", + "0xMetadataViews": "0x631e88ae7f1d7c20", + "0xViewResolver": "0x631e88ae7f1d7c20", + "0xNonFungibleToken": "0x631e88ae7f1d7c20", + "0xFungibleToken": "0x9a0766d93b6608b7", + "0xFungibleTokenSwitchboard": "0x9a0766d93b6608b7", + "0xFlowbox": "0xbca26f5091cd39ec", + "0xFlowviewAccountBookmark": "0xdc34f5a7b807bcfb", + "0xNFTStorefrontV2": "0x2d55b98eb200daef", + + "0xHybridCustody": "0x294e44e1ec6993c6", + "0xCapabilityFactory": "0x294e44e1ec6993c6", + "0xCapabilityFilter": "0x294e44e1ec6993c6", + "0xCapabilityDelegator": "0x294e44e1ec6993c6", + "0xFindViews": "0x35717efbbce11c74", + "0xFlowmap": "0x72ed11a540a52efc", + }); + } else { + cfg = config({ + "flow.network": "mainnet", + "accessNode.api": + "https://floral-special-valley.flow-mainnet.quiknode.pro", + "discovery.wallet": "https://fcl-discovery.onflow.org/authn", + "sdk.transport": httpSend, + "app.detail.title": "flowview", + "app.detail.icon": "https://i.imgur.com/YL8MLEd.png", + + "0xFlowToken": "0x1654653399040a61", + "0xNFTCatalog": "0x49a7cda3a1eecc29", + "0xMetadataViews": "0x1d7e57aa55817448", + "0xViewResolver": "0x1d7e57aa55817448", + "0xNonFungibleToken": "0x1d7e57aa55817448", + "0xFungibleToken": "0xf233dcee88fe0abe", + "0xFungibleTokenSwitchboard": "0xf233dcee88fe0abe", + "0xFlowbox": "0x1b3930856571a52b", + "0xFlowviewAccountBookmark": "0x39b144ab4d348e2b", + "0xNFTStorefrontV2": "0x4eb8a10cb9f87357", + + "0xHybridCustody": "0xd8a7e05a7ac670c0", + "0xCapabilityFactory": "0xd8a7e05a7ac670c0", + "0xCapabilityFilter": "0xd8a7e05a7ac670c0", + "0xCapabilityDelegator": "0xd8a7e05a7ac670c0", + "0xFindViews": "0x097bafa4e0b48eef", + "0xFlowmap": "0x483f0fe77f0d59fb", + }); + } + + const flowJSON = await fetch("/flow.json"); + await cfg.load({ flowJSON: flowJSON ?? {} }); +} +main(); diff --git a/lib/utils.js b/lib/utils.js index 3e4ef53..10a1502 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -193,7 +193,7 @@ export const getImageSrcFromMetadataViewsFile = (file) => { } else { return getIPFSFileURL(file.cid.trim(), null) } - } else if (file.url.includes('data:image/')) { + } else if (file.url && file.url.includes('data:image/')) { return file.url } else { return "/token_placeholder.png" @@ -426,4 +426,4 @@ export const flowmapToName = (inscription) => { export const flowmapDisplayName = (inscription) => { return `${inscription}\nname: ${flowmapToName(inscription)}` -} \ No newline at end of file +} diff --git a/public/flow.json b/public/flow.json new file mode 100644 index 0000000..8ebbb2b --- /dev/null +++ b/public/flow.json @@ -0,0 +1,244 @@ +{ + "contracts": { + "FlowviewAccountBookmark": { + "source": "./cadence/contracts/FlowviewAccountBookmark.cdc", + "aliases": { + "testnet": "0xdc34f5a7b807bcfb", + "mainnet": "0x39b144ab4d348e2b" + } + }, + "Burner": { + "source": "imports/9a0766d93b6608b7/Burner.cdc", + "hash": "71af18e227984cd434a3ad00bb2f3618b76482842bae920ee55662c37c8bf331", + "aliases": { + "testnet": "9a0766d93b6608b7" + } + }, + "CapabilityDelegator": { + "source": "imports/294e44e1ec6993c6/CapabilityDelegator.cdc", + "hash": "ad3bf8671a74a836b428da7840540c0ce419349be5f6410b18546e9a9217a9d2", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "CapabilityFactory": { + "source": "imports/294e44e1ec6993c6/CapabilityFactory.cdc", + "hash": "33d6b142c1db548a193cc06ff9828a24ca2ff8726301e292a8b6863dd0e1e73e", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "CapabilityFilter": { + "source": "imports/294e44e1ec6993c6/CapabilityFilter.cdc", + "hash": "77b59eb8245102a84a49d47a67e83eeeaafea920b120cdd6aa175d9ff120c388", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "FlowToken": { + "source": "imports/7e60df042a9c0868/FlowToken.cdc", + "hash": "a7b219cf8596c1116aa219bb31535faa79ebf5e02d16fa594acd0398057674e1", + "aliases": { + "emulator": "0ae53cb6e3f42a79", + "mainnet": "1654653399040a61", + "previewnet": "4445e7ad11568276", + "testnet": "7e60df042a9c0868" + } + }, + "FungibleToken": { + "source": "imports/9a0766d93b6608b7/FungibleToken.cdc", + "hash": "154d9000cc0b992664c1d315826a4bc47e744fbc7f2e99daf823e5101945042a", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "previewnet": "a0225e7000ac82a9", + "testnet": "9a0766d93b6608b7" + } + }, + "FungibleTokenMetadataViews": { + "source": "imports/9a0766d93b6608b7/FungibleTokenMetadataViews.cdc", + "hash": "64ec97395c0a3958510ea663563f59d5a6beb7943d69b903db94c11d76be6296", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "previewnet": "a0225e7000ac82a9", + "testnet": "9a0766d93b6608b7" + } + }, + "FungibleTokenSwitchboard": { + "source": "imports/9a0766d93b6608b7/FungibleTokenSwitchboard.cdc", + "hash": "b8dccf6eeb12945b2f8d0f19cb5bfc672d6a8cc226d919c2cd2ed4c137088de2", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "previewnet": "a0225e7000ac82a9", + "testnet": "9a0766d93b6608b7" + } + }, + "HybridCustody": { + "source": "imports/294e44e1ec6993c6/HybridCustody.cdc", + "hash": "a288e9ca3315cb744cfd45671a86b52183d7007006b42dc24bd996fbc1d96bcd", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "MetadataViews": { + "source": "imports/631e88ae7f1d7c20/MetadataViews.cdc", + "hash": "77e2c3c4afb855af657ecae6611a99acf47a102144c68f4663de42ae700adf5b", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "previewnet": "b6763b4399a888c8", + "testnet": "631e88ae7f1d7c20" + } + }, + "NFTStorefrontV2": { + "source": "imports/2d55b98eb200daef/NFTStorefrontV2.cdc", + "hash": "c3e5da9b36f8b830d15ebbde6fb1c4ad1b903ad818030da75f004c8a31503586", + "aliases": { + "testnet": "2d55b98eb200daef" + } + }, + "NonFungibleToken": { + "source": "imports/631e88ae7f1d7c20/NonFungibleToken.cdc", + "hash": "ea1b5fa55b6648064c77a6fd83084a3a0be2a6f4386b3b259c89e4f62ab8f6c0", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "previewnet": "b6763b4399a888c8", + "testnet": "631e88ae7f1d7c20" + } + }, + "ViewResolver": { + "source": "imports/631e88ae7f1d7c20/ViewResolver.cdc", + "hash": "374a1994046bac9f6228b4843cb32393ef40554df9bd9907a702d098a2987bde", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "previewnet": "b6763b4399a888c8", + "testnet": "631e88ae7f1d7c20" + } + } + }, + "dependencies": { + "Burner": { + "source": "testnet://9a0766d93b6608b7.Burner", + "hash": "71af18e227984cd434a3ad00bb2f3618b76482842bae920ee55662c37c8bf331", + "aliases": { + "testnet": "9a0766d93b6608b7" + } + }, + "CapabilityDelegator": { + "source": "testnet://294e44e1ec6993c6.CapabilityDelegator", + "hash": "ad3bf8671a74a836b428da7840540c0ce419349be5f6410b18546e9a9217a9d2", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "CapabilityFactory": { + "source": "testnet://294e44e1ec6993c6.CapabilityFactory", + "hash": "33d6b142c1db548a193cc06ff9828a24ca2ff8726301e292a8b6863dd0e1e73e", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "CapabilityFilter": { + "source": "testnet://294e44e1ec6993c6.CapabilityFilter", + "hash": "77b59eb8245102a84a49d47a67e83eeeaafea920b120cdd6aa175d9ff120c388", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "FlowToken": { + "source": "testnet://7e60df042a9c0868.FlowToken", + "hash": "a7b219cf8596c1116aa219bb31535faa79ebf5e02d16fa594acd0398057674e1", + "aliases": { + "emulator": "0ae53cb6e3f42a79", + "mainnet": "1654653399040a61", + "previewnet": "4445e7ad11568276", + "testnet": "7e60df042a9c0868" + } + }, + "FungibleToken": { + "source": "testnet://9a0766d93b6608b7.FungibleToken", + "hash": "154d9000cc0b992664c1d315826a4bc47e744fbc7f2e99daf823e5101945042a", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "previewnet": "a0225e7000ac82a9", + "testnet": "9a0766d93b6608b7" + } + }, + "FungibleTokenMetadataViews": { + "source": "testnet://9a0766d93b6608b7.FungibleTokenMetadataViews", + "hash": "64ec97395c0a3958510ea663563f59d5a6beb7943d69b903db94c11d76be6296", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "previewnet": "a0225e7000ac82a9", + "testnet": "9a0766d93b6608b7" + } + }, + "FungibleTokenSwitchboard": { + "source": "testnet://9a0766d93b6608b7.FungibleTokenSwitchboard", + "hash": "b8dccf6eeb12945b2f8d0f19cb5bfc672d6a8cc226d919c2cd2ed4c137088de2", + "aliases": { + "emulator": "ee82856bf20e2aa6", + "mainnet": "f233dcee88fe0abe", + "previewnet": "a0225e7000ac82a9", + "testnet": "9a0766d93b6608b7" + } + }, + "HybridCustody": { + "source": "testnet://294e44e1ec6993c6.HybridCustody", + "hash": "a288e9ca3315cb744cfd45671a86b52183d7007006b42dc24bd996fbc1d96bcd", + "aliases": { + "testnet": "294e44e1ec6993c6" + } + }, + "MetadataViews": { + "source": "testnet://631e88ae7f1d7c20.MetadataViews", + "hash": "77e2c3c4afb855af657ecae6611a99acf47a102144c68f4663de42ae700adf5b", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "previewnet": "b6763b4399a888c8", + "testnet": "631e88ae7f1d7c20" + } + }, + "NFTStorefrontV2": { + "source": "testnet://2d55b98eb200daef.NFTStorefrontV2", + "hash": "c3e5da9b36f8b830d15ebbde6fb1c4ad1b903ad818030da75f004c8a31503586", + "aliases": { + "testnet": "2d55b98eb200daef" + } + }, + "NonFungibleToken": { + "source": "testnet://631e88ae7f1d7c20.NonFungibleToken", + "hash": "ea1b5fa55b6648064c77a6fd83084a3a0be2a6f4386b3b259c89e4f62ab8f6c0", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "previewnet": "b6763b4399a888c8", + "testnet": "631e88ae7f1d7c20" + } + }, + "ViewResolver": { + "source": "testnet://631e88ae7f1d7c20.ViewResolver", + "hash": "374a1994046bac9f6228b4843cb32393ef40554df9bd9907a702d098a2987bde", + "aliases": { + "emulator": "f8d6e0586b0a20c7", + "mainnet": "1d7e57aa55817448", + "previewnet": "b6763b4399a888c8", + "testnet": "631e88ae7f1d7c20" + } + } + }, + "networks": { + "emulator": "127.0.0.1:3569", + "mainnet": "access.mainnet.nodes.onflow.org:9000", + "previewnet": "access.previewnet.nodes.onflow.org:9000", + "testing": "127.0.0.1:3569", + "testnet": "access.devnet.nodes.onflow.org:9000" + } +} \ No newline at end of file diff --git a/public/scripts/basic/get_account_info.cdc b/public/scripts/basic/get_account_info.cdc index 7d2e599..4111647 100644 --- a/public/scripts/basic/get_account_info.cdc +++ b/public/scripts/basic/get_account_info.cdc @@ -1,9 +1,9 @@ -pub struct Result { - pub let address: Address - pub let balance: UFix64 - pub let availableBalance: UFix64 - pub let storageUsed: UInt64 - pub let storageCapacity: UInt64 +access(all) struct Result { + access(all) let address: Address + access(all) let balance: UFix64 + access(all) let availableBalance: UFix64 + access(all) let storageUsed: UInt64 + access(all) let storageCapacity: UInt64 init( address: Address, @@ -20,13 +20,13 @@ pub struct Result { } } -pub fun main(address: Address): Result { - let account = getAuthAccount(address) +access(all) fun main(address: Address): Result { + let account = getAuthAccount(address) return Result( address: account.address, balance: account.balance, availableBalance: account.availableBalance, - storageUsed: account.storageUsed, - storageCapacity: account.storageCapacity + storageUsed: account.storage.used, + storageCapacity: account.storage.capacity ) } \ No newline at end of file diff --git a/public/scripts/bookmark/account/get_bookmark.cdc b/public/scripts/bookmark/account/get_bookmark.cdc index ed9c8c5..ec96a6f 100644 --- a/public/scripts/bookmark/account/get_bookmark.cdc +++ b/public/scripts/bookmark/account/get_bookmark.cdc @@ -1,8 +1,8 @@ -import FlowviewAccountBookmark from 0xFlowviewAccountBookmark +import "FlowviewAccountBookmark" -pub fun main(owner: Address, target: Address): &FlowviewAccountBookmark.AccountBookmark{FlowviewAccountBookmark.AccountBookmarkPublic}? { - let acct = getAuthAccount(owner) - if let collection = acct.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) { +access(all) fun main(owner: Address, target: Address): &FlowviewAccountBookmark.AccountBookmark? { + let acct = getAuthAccount(owner) + if let collection = acct.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) { return collection.borrowPublicAccountBookmark(address: target) } diff --git a/public/scripts/bookmark/account/get_bookmarks.cdc b/public/scripts/bookmark/account/get_bookmarks.cdc index 7cb659d..6feef6e 100644 --- a/public/scripts/bookmark/account/get_bookmarks.cdc +++ b/public/scripts/bookmark/account/get_bookmarks.cdc @@ -1,8 +1,8 @@ -import FlowviewAccountBookmark from 0xFlowviewAccountBookmark +import "FlowviewAccountBookmark" -pub fun main(owner: Address): &{Address: FlowviewAccountBookmark.AccountBookmark{FlowviewAccountBookmark.AccountBookmarkPublic}}? { - let acct = getAuthAccount(owner) - let collection = acct.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) +access(all) fun main(owner: Address): &{Address: FlowviewAccountBookmark.AccountBookmark}? { + let acct = getAuthAccount(owner) + let collection = acct.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow account bookmark collection") return collection.getAccountBookmarks() diff --git a/public/scripts/collection/get_catalog_type_data.cdc b/public/scripts/collection/get_catalog_type_data.cdc index a590186..aa4db78 100644 --- a/public/scripts/collection/get_catalog_type_data.cdc +++ b/public/scripts/collection/get_catalog_type_data.cdc @@ -1,6 +1,6 @@ import NFTCatalog from 0xNFTCatalog -pub fun main(): {String : {String : Bool}} { +access(all) fun main(): {String : {String : Bool}} { let catalog = NFTCatalog.getCatalogTypeData() return catalog } \ No newline at end of file diff --git a/public/scripts/collection/get_nft_catalog_by_collection_ids.cdc b/public/scripts/collection/get_nft_catalog_by_collection_ids.cdc index 728c93d..6c7a1b0 100644 --- a/public/scripts/collection/get_nft_catalog_by_collection_ids.cdc +++ b/public/scripts/collection/get_nft_catalog_by_collection_ids.cdc @@ -1,6 +1,6 @@ import NFTCatalog from 0xNFTCatalog -pub fun main(collectionIdentifiers: [String]): {String: NFTCatalog.NFTCatalogMetadata} { +access(all) fun main(collectionIdentifiers: [String]): {String: NFTCatalog.NFTCatalogMetadata} { let res: {String: NFTCatalog.NFTCatalogMetadata} = {} for collectionID in collectionIdentifiers { if let catalog = NFTCatalog.getCatalogEntry(collectionIdentifier: collectionID) { diff --git a/public/scripts/collection/get_nft_displays.cdc b/public/scripts/collection/get_nft_displays.cdc index 7128ea9..647f6fa 100644 --- a/public/scripts/collection/get_nft_displays.cdc +++ b/public/scripts/collection/get_nft_displays.cdc @@ -3,14 +3,14 @@ import MetadataViews from 0xMetadataViews import FindViews from 0xFindViews import Flowmap from 0xFlowmap -pub struct ViewInfo { - pub let name: String - pub let description: String - pub let thumbnail: AnyStruct{MetadataViews.File} - pub let rarity: String? - pub let transferrable: Bool - pub let collectionDisplay: MetadataViews.NFTCollectionDisplay? - pub let inscription: String +access(all) struct ViewInfo { + access(all) let name: String + access(all) let description: String + access(all) let thumbnail: AnyStruct{MetadataViews.File} + access(all) let rarity: String? + access(all) let transferrable: Bool + access(all) let collectionDisplay: MetadataViews.NFTCollectionDisplay? + access(all) let inscription: String init(name: String, description: String, thumbnail: AnyStruct{MetadataViews.File}, rarity: String?, transferrable: Bool, collectionDisplay: MetadataViews.NFTCollectionDisplay?, inscription: String) { self.name = name @@ -23,8 +23,8 @@ pub struct ViewInfo { } } -pub fun main(address: Address, storagePathID: String, tokenIDs: [UInt64]): {UInt64: ViewInfo} { - let account = getAuthAccount(address) +access(all) fun main(address: Address, storagePathID: String, tokenIDs: [UInt64]): {UInt64: ViewInfo} { + let account = getAuthAccount(address) let res: {UInt64: ViewInfo} = {} var collectionDisplayFetched = false diff --git a/public/scripts/collection/get_nft_displays_emulator.cdc b/public/scripts/collection/get_nft_displays_emulator.cdc index 7e65252..39ed7b4 100644 --- a/public/scripts/collection/get_nft_displays_emulator.cdc +++ b/public/scripts/collection/get_nft_displays_emulator.cdc @@ -1,13 +1,14 @@ import NonFungibleToken from 0xNonFungibleToken import MetadataViews from 0xMetadataViews +import ViewResolver from 0xViewResolver -pub struct ViewInfo { - pub let name: String - pub let description: String - pub let thumbnail: AnyStruct{MetadataViews.File} - pub let rarity: String? - pub let transferrable: Bool - pub let collectionDisplay: MetadataViews.NFTCollectionDisplay? +access(all) struct ViewInfo { + access(all) let name: String + access(all) let description: String + access(all) let thumbnail: {MetadataViews.File} + access(all) let rarity: String? + access(all) let transferrable: Bool + access(all) let collectionDisplay: MetadataViews.NFTCollectionDisplay? init(name: String, description: String, thumbnail: AnyStruct{MetadataViews.File}, rarity: String?, transferrable: Bool, collectionDisplay: MetadataViews.NFTCollectionDisplay?) { self.name = name @@ -19,8 +20,8 @@ pub struct ViewInfo { } } -pub fun main(address: Address, storagePathID: String, tokenIDs: [UInt64]): {UInt64: ViewInfo} { - let account = getAuthAccount(address) +access(all) fun main(address: Address, storagePathID: String, tokenIDs: [UInt64]): {UInt64: ViewInfo} { + let account = getAuthAccount(address) let res: {UInt64: ViewInfo} = {} var collectionDisplayFetched = false @@ -34,7 +35,7 @@ pub fun main(address: Address, storagePathID: String, tokenIDs: [UInt64]): {UInt return res } - let metadataViewType = Type<@AnyResource{MetadataViews.ResolverCollection}>() + let metadataViewType = Type<@{MetadataViews.ResolverCollection}>() let conformedMetadataViews = type!.isSubtype(of: metadataViewType) if !conformedMetadataViews { diff --git a/public/scripts/collection/get_nft_metadata_views.cdc b/public/scripts/collection/get_nft_metadata_views.cdc index 5eed7a3..697134e 100644 --- a/public/scripts/collection/get_nft_metadata_views.cdc +++ b/public/scripts/collection/get_nft_metadata_views.cdc @@ -2,13 +2,13 @@ import NonFungibleToken from 0xNonFungibleToken import MetadataViews from 0xMetadataViews import FindViews from 0xFindViews -pub struct CollectionData { - pub let storagePath: StoragePath - pub let publicPath: PublicPath - pub let providerPath: PrivatePath - pub let publicCollection: Type - pub let publicLinkedType: Type - pub let providerLinkedType: Type +access(all) struct CollectionData { + access(all) let storagePath: StoragePath + access(all) let publicPath: PublicPath + access(all) let providerPath: PrivatePath + access(all) let publicCollection: Type + access(all) let publicLinkedType: Type + access(all) let providerLinkedType: Type init( storagePath: StoragePath, @@ -27,8 +27,8 @@ pub struct CollectionData { } } -pub fun main(address: Address, storagePathID: String, tokenID: UInt64): {String: AnyStruct} { - let account = getAuthAccount(address) +access(all) fun main(address: Address, storagePathID: String, tokenID: UInt64): {String: AnyStruct} { + let account = getAuthAccount(address) let res: {String: AnyStruct} = {} let path = StoragePath(identifier: storagePathID)! diff --git a/public/scripts/collection/get_nft_metadata_views_emulator.cdc b/public/scripts/collection/get_nft_metadata_views_emulator.cdc index 729d2fc..e28599d 100644 --- a/public/scripts/collection/get_nft_metadata_views_emulator.cdc +++ b/public/scripts/collection/get_nft_metadata_views_emulator.cdc @@ -1,13 +1,13 @@ import NonFungibleToken from 0xNonFungibleToken import MetadataViews from 0xMetadataViews -pub struct CollectionData { - pub let storagePath: StoragePath - pub let publicPath: PublicPath - pub let providerPath: PrivatePath - pub let publicCollection: Type - pub let publicLinkedType: Type - pub let providerLinkedType: Type +access(all) struct CollectionData { + access(all) let storagePath: StoragePath + access(all) let publicPath: PublicPath + access(all) let providerPath: PrivatePath + access(all) let publicCollection: Type + access(all) let publicLinkedType: Type + access(all) let providerLinkedType: Type init( storagePath: StoragePath, @@ -26,8 +26,8 @@ pub struct CollectionData { } } -pub fun main(address: Address, storagePathID: String, tokenID: UInt64): {String: AnyStruct} { - let account = getAuthAccount(address) +access(all) fun main(address: Address, storagePathID: String, tokenID: UInt64): {String: AnyStruct} { + let account = getAuthAccount(address) let res: {String: AnyStruct} = {} let path = StoragePath(identifier: storagePathID)! diff --git a/public/scripts/contract/get_contract_names.cdc b/public/scripts/contract/get_contract_names.cdc index a997af2..c707842 100644 --- a/public/scripts/contract/get_contract_names.cdc +++ b/public/scripts/contract/get_contract_names.cdc @@ -1,4 +1,9 @@ -pub fun main(address: Address): [String] { +access(all) fun main(address: Address): [String] { let account = getAccount(address) - return account.contracts.names + let names = account.contracts.names + let retNames: [String] = [] + for name in names { + retNames.append(name) + } + return retNames } \ No newline at end of file diff --git a/public/scripts/domain/get_address_of_domain.cdc b/public/scripts/domain/get_address_of_domain.cdc index 777d61c..0a55f99 100644 --- a/public/scripts/domain/get_address_of_domain.cdc +++ b/public/scripts/domain/get_address_of_domain.cdc @@ -1,5 +1,5 @@ import DomainUtils from 0xFlowbox -pub fun main(name: String, root: String): Address? { +access(all) fun main(name: String, root: String): Address? { return DomainUtils.getAddressOfDomain(name: name, root: root) } \ No newline at end of file diff --git a/public/scripts/domain/get_default_domains_of_address.cdc b/public/scripts/domain/get_default_domains_of_address.cdc index 3019507..0364006 100644 --- a/public/scripts/domain/get_default_domains_of_address.cdc +++ b/public/scripts/domain/get_default_domains_of_address.cdc @@ -1,5 +1,5 @@ import DomainUtils from 0xFlowbox -pub fun main(address: Address): {String: String} { +access(all) fun main(address: Address): {String: String} { return DomainUtils.getDefaultDomainsOfAddress(address) } \ No newline at end of file diff --git a/public/scripts/hc/get_hc_manager_info.cdc b/public/scripts/hc/get_hc_manager_info.cdc index 3488599..670a3c1 100644 --- a/public/scripts/hc/get_hc_manager_info.cdc +++ b/public/scripts/hc/get_hc_manager_info.cdc @@ -1,14 +1,14 @@ -import HybridCustody from 0xHybridCustody -import MetadataViews from 0xMetadataViews -import CapabilityFactory from 0xCapabilityFactory -import CapabilityFilter from 0xCapabilityFilter +import "HybridCustody" +import "MetadataViews" +import "CapabilityFactory" +import "CapabilityFilter" -pub struct ChildAccountInfo { - pub let address: Address - pub let display: MetadataViews.Display? - pub let factorySupportedTypes: [Type]? - pub let filterDetails: AnyStruct? - pub let managerFilterDetails: AnyStruct? +access(all) struct ChildAccountInfo { + access(all) let address: Address + access(all) let display: MetadataViews.Display? + access(all) let factorySupportedTypes: [Type]? + access(all) let filterDetails: AnyStruct? + access(all) let managerFilterDetails: AnyStruct? init( address: Address, @@ -25,10 +25,10 @@ pub struct ChildAccountInfo { } } -pub struct ManagerInfo { - pub let childAccounts: [ChildAccountInfo] - pub let ownedAccounts: [ChildAccountInfo] - pub let isManagerExists: Bool +access(all) struct ManagerInfo { + access(all) let childAccounts: [ChildAccountInfo] + access(all) let ownedAccounts: [ChildAccountInfo] + access(all) let isManagerExists: Bool init( childAccounts: [ChildAccountInfo], @@ -41,9 +41,9 @@ pub struct ManagerInfo { } } -pub fun main(child: Address): ManagerInfo { - let acct = getAuthAccount(child) - let m = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) +access(all) fun main(child: Address): ManagerInfo { + let acct = getAuthAccount(child) + let m = acct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) if let manager = m { return ManagerInfo( @@ -60,7 +60,7 @@ pub fun main(child: Address): ManagerInfo { ) } -pub fun getChildAccounts(manager: &HybridCustody.Manager): [ChildAccountInfo] { +access(all) fun getChildAccounts(manager: &HybridCustody.Manager): [ChildAccountInfo] { let childAddresses = manager.getChildAddresses() let children: [ChildAccountInfo] = [] for childAddress in childAddresses { @@ -86,7 +86,7 @@ pub fun getChildAccounts(manager: &HybridCustody.Manager): [ChildAccountInfo] { return children } -pub fun getOwnedAccounts(manager: &HybridCustody.Manager): [ChildAccountInfo] { +access(all) fun getOwnedAccounts(manager: &HybridCustody.Manager): [ChildAccountInfo] { let ownedAddresses = manager.getOwnedAddresses() let children: [ChildAccountInfo] = [] for ownedAddress in ownedAddresses { diff --git a/public/scripts/hc/get_owned_account_info.cdc b/public/scripts/hc/get_owned_account_info.cdc index a878258..b020729 100644 --- a/public/scripts/hc/get_owned_account_info.cdc +++ b/public/scripts/hc/get_owned_account_info.cdc @@ -1,13 +1,13 @@ -import HybridCustody from 0xHybridCustody -import MetadataViews from 0xMetadataViews -import CapabilityFactory from 0xCapabilityFactory -import CapabilityFilter from 0xCapabilityFilter +import "HybridCustody" +import "MetadataViews" +import "CapabilityFactory" +import "CapabilityFilter" -pub struct OwnedAccountInfo { - pub let display: MetadataViews.Display? - pub let parents: [ParentInfo] - pub let owner: Address? - pub let isOwnedAccountExists: Bool +access(all) struct OwnedAccountInfo { + access(all) let display: MetadataViews.Display? + access(all) let parents: [ParentInfo] + access(all) let owner: Address? + access(all) let isOwnedAccountExists: Bool init( display: MetadataViews.Display?, @@ -22,10 +22,10 @@ pub struct OwnedAccountInfo { } } -pub struct ParentInfo { - pub let address: Address - pub let isClaimed: Bool - pub let childAccount: ChildAccountInfo? +access(all) struct ParentInfo { + access(all) let address: Address + access(all) let isClaimed: Bool + access(all) let childAccount: ChildAccountInfo? init( address: Address, @@ -38,12 +38,12 @@ pub struct ParentInfo { } } -pub struct ChildAccountInfo { - pub let factory: Capability<&CapabilityFactory.Manager{CapabilityFactory.Getter}> - pub let filter: Capability<&{CapabilityFilter.Filter}> +access(all) struct ChildAccountInfo { + access(all) let factory: Capability<&CapabilityFactory.Manager> + access(all) let filter: Capability<&{CapabilityFilter.Filter}> init( - factory: Capability<&CapabilityFactory.Manager{CapabilityFactory.Getter}>, + factory: Capability<&CapabilityFactory.Manager>, filter: Capability<&{CapabilityFilter.Filter}> ) { self.factory = factory @@ -51,9 +51,9 @@ pub struct ChildAccountInfo { } } -pub fun main(child: Address): OwnedAccountInfo { - let acct = getAuthAccount(child) - let o = acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) +access(all) fun main(child: Address): OwnedAccountInfo { + let acct = getAuthAccount(child) + let o = acct.storage.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) if let owned = o { let viewType = Type() let display = owned.resolveView(viewType) as! MetadataViews.Display? diff --git a/public/scripts/staking/get_delegator_info.cdc b/public/scripts/staking/get_delegator_info.cdc index 4e2644b..4e4cc93 100644 --- a/public/scripts/staking/get_delegator_info.cdc +++ b/public/scripts/staking/get_delegator_info.cdc @@ -1,5 +1,5 @@ import FlowIDTableStaking from 0x8624b52f9ddcd04a -pub fun main(nodeID: String, delegatorID: UInt32): FlowIDTableStaking.DelegatorInfo { +access(all) fun main(nodeID: String, delegatorID: UInt32): FlowIDTableStaking.DelegatorInfo { return FlowIDTableStaking.DelegatorInfo(nodeID: nodeID, delegatorID: delegatorID) } \ No newline at end of file diff --git a/public/scripts/staking/get_epoch_metadata.cdc b/public/scripts/staking/get_epoch_metadata.cdc index fe91fa4..228d7ba 100644 --- a/public/scripts/staking/get_epoch_metadata.cdc +++ b/public/scripts/staking/get_epoch_metadata.cdc @@ -1,5 +1,5 @@ import FlowEpoch from 0x8624b52f9ddcd04a -pub fun main(epochCounter: UInt64): FlowEpoch.EpochMetadata? { +access(all) fun main(epochCounter: UInt64): FlowEpoch.EpochMetadata? { return FlowEpoch.getEpochMetadata(epochCounter) } \ No newline at end of file diff --git a/public/scripts/staking/get_node_info.cdc b/public/scripts/staking/get_node_info.cdc index 6966611..db73497 100644 --- a/public/scripts/staking/get_node_info.cdc +++ b/public/scripts/staking/get_node_info.cdc @@ -1,5 +1,5 @@ import FlowIDTableStaking from 0x8624b52f9ddcd04a -pub fun main(nodeID: String): FlowIDTableStaking.NodeInfo { +access(all) fun main(nodeID: String): FlowIDTableStaking.NodeInfo { return FlowIDTableStaking.NodeInfo(nodeID: nodeID) } \ No newline at end of file diff --git a/public/scripts/staking/get_staking_info.cdc b/public/scripts/staking/get_staking_info.cdc index dd7d6c3..bec6884 100644 --- a/public/scripts/staking/get_staking_info.cdc +++ b/public/scripts/staking/get_staking_info.cdc @@ -3,9 +3,9 @@ import FlowIDTableStaking from 0x8624b52f9ddcd04a import FlowEpoch from 0x8624b52f9ddcd04a import FlowStakingCollection from 0x8d0e87b65159ae63 -pub struct EpochInfo { - pub let currentEpochCounter: UInt64 - pub let currentEpochPhase: UInt8 +access(all) struct EpochInfo { + access(all) let currentEpochCounter: UInt64 + access(all) let currentEpochPhase: UInt8 init( currentEpochCounter: UInt64, @@ -16,18 +16,18 @@ pub struct EpochInfo { } } -pub struct Result { - pub let stakingInfo: StakingInfo? +access(all) struct Result { + access(all) let stakingInfo: StakingInfo? init(stakingInfo: StakingInfo?) { self.stakingInfo = stakingInfo } } -pub struct LockedAccountInfo { - pub let lockedAddress: Address - pub let lockedBalance: UFix64 - pub let unlockLimit: UFix64 +access(all) struct LockedAccountInfo { + access(all) let lockedAddress: Address + access(all) let lockedBalance: UFix64 + access(all) let unlockLimit: UFix64 init( lockedAddress: Address, @@ -40,12 +40,12 @@ pub struct LockedAccountInfo { } } -pub struct StakingInfo { - pub let epochInfo: EpochInfo - pub let lockedAccountInfo: LockedAccountInfo? - pub let nodeInfos: [NodeInfo] - pub let delegatorInfos: [DelegatorInfo] - pub let machineAccounts: {String: FlowStakingCollection.MachineAccountInfo} +access(all) struct StakingInfo { + access(all) let epochInfo: EpochInfo + access(all) let lockedAccountInfo: LockedAccountInfo? + access(all) let nodeInfos: [NodeInfo] + access(all) let delegatorInfos: [DelegatorInfo] + access(all) let machineAccounts: {String: FlowStakingCollection.MachineAccountInfo} init( epochInfo: EpochInfo, @@ -62,19 +62,19 @@ pub struct StakingInfo { } } -pub struct NodeInfo { - pub let id: String - pub let networkingAddress: String - pub let role: UInt8 - pub let tokensStaked: UFix64 - pub let tokensCommitted: UFix64 - pub let tokensUnstaking: UFix64 - pub let tokensUnstaked: UFix64 - pub let tokensRewarded: UFix64 +access(all) struct NodeInfo { + access(all) let id: String + access(all) let networkingAddress: String + access(all) let role: UInt8 + access(all) let tokensStaked: UFix64 + access(all) let tokensCommitted: UFix64 + access(all) let tokensUnstaking: UFix64 + access(all) let tokensUnstaked: UFix64 + access(all) let tokensRewarded: UFix64 - pub let delegatorIDCounter: UInt32 - pub let tokensRequestedToUnstake: UFix64 - pub let initialWeight: UInt64 + access(all) let delegatorIDCounter: UInt32 + access(all) let tokensRequestedToUnstake: UFix64 + access(all) let initialWeight: UInt64 init(nodeID: String) { let nodeInfo = FlowIDTableStaking.NodeInfo(nodeID: nodeID) @@ -93,16 +93,16 @@ pub struct NodeInfo { } } -pub struct DelegatorInfo { - pub let id: UInt32 - pub let nodeID: String - pub let nodeInfo: NodeInfo - pub let tokensCommitted: UFix64 - pub let tokensStaked: UFix64 - pub let tokensUnstaking: UFix64 - pub let tokensRewarded: UFix64 - pub let tokensUnstaked: UFix64 - pub let tokensRequestedToUnstake: UFix64 +access(all) struct DelegatorInfo { + access(all) let id: UInt32 + access(all) let nodeID: String + access(all) let nodeInfo: NodeInfo + access(all) let tokensCommitted: UFix64 + access(all) let tokensStaked: UFix64 + access(all) let tokensUnstaking: UFix64 + access(all) let tokensRewarded: UFix64 + access(all) let tokensUnstaked: UFix64 + access(all) let tokensRequestedToUnstake: UFix64 init(nodeID: String, delegatorID: UInt32) { let delegatorInfo = FlowIDTableStaking.DelegatorInfo(nodeID: nodeID, delegatorID: delegatorID) @@ -120,14 +120,14 @@ pub struct DelegatorInfo { } } -pub fun main(address: Address): Result { +access(all) fun main(address: Address): Result { let epochInfo = EpochInfo( currentEpochCounter: FlowEpoch.currentEpochCounter, currentEpochPhase: FlowEpoch.currentEpochPhase.rawValue ) let tokenHolderRef = - getAuthAccount(address) + getAuthAccount(address) .borrow<&LockedTokens.TokenHolder>(from: LockedTokens.TokenHolderStoragePath) var stakingInfo: StakingInfo? = nil @@ -171,7 +171,7 @@ pub fun main(address: Address): Result { ) } else { let stakingCollectionRef = - getAuthAccount(address) + getAuthAccount(address) .borrow<&FlowStakingCollection.StakingCollection>(from: FlowStakingCollection.StakingCollectionStoragePath) if let stakingCollection = stakingCollectionRef { diff --git a/public/scripts/storage/get_basic_public_items.cdc b/public/scripts/storage/get_basic_public_items.cdc index 5d7cad7..8f2f5e6 100644 --- a/public/scripts/storage/get_basic_public_items.cdc +++ b/public/scripts/storage/get_basic_public_items.cdc @@ -1,7 +1,7 @@ -pub struct Item { - pub let address: Address - pub let path: String - pub let targetPath: String? +access(all) struct Item { + access(all) let address: Address + access(all) let path: String + access(all) let targetPath: String? init(address: Address, path: String, targetPath: String?) { self.address = address @@ -10,19 +10,21 @@ pub struct Item { } } -pub fun main(address: Address): [Item] { - let account = getAuthAccount(address) +access(all) fun main(address: Address): [Item] { + let account = getAuthAccount(address) let items: [Item] = [] __OUTDATED_PATHS__ - for path in account.publicPaths { + for path in account.storage.publicPaths { if (outdatedPaths.containsKey(path)) { continue } var targetPath: String? = nil - if let target = account.getLinkTarget(path) { - targetPath = target.toString() + // FIXME: This is a workaround to check if the path is a capability + // There is no getLinkTarget method anymore + if account.capabilities.exists(path) { + targetPath = path.toString() } let item = Item(address: address, path: path.toString(), targetPath: targetPath) diff --git a/public/scripts/storage/get_private_items.cdc b/public/scripts/storage/get_private_items.cdc index a864210..59183b5 100644 --- a/public/scripts/storage/get_private_items.cdc +++ b/public/scripts/storage/get_private_items.cdc @@ -1,8 +1,8 @@ -pub struct Item { - pub let address: Address - pub let path: String - pub let type: Type - pub let targetPath: String? +access(all) struct Item { + access(all) let address: Address + access(all) let path: String + access(all) let type: Type + access(all) let targetPath: String? init( address: Address, @@ -17,30 +17,31 @@ pub struct Item { } } -pub fun main(address: Address, pathMap: {String: Bool}): [Item] { - let account = getAuthAccount(address) +access(all) fun main(address: Address, pathMap: {String: Bool}): [Item] { + // let account = getAuthAccount(address) - let items: [Item] = [] - account.forEachPrivate(fun (path: PrivatePath, type: Type): Bool { - if !pathMap.containsKey(path.toString()) { - return true - } + // let items: [Item] = [] + // account.forEachPrivate(fun (path: PrivatePath, type: Type): Bool { + // if !pathMap.containsKey(path.toString()) { + // return true + // } - var targetPath: String? = nil - if let target = account.getLinkTarget(path) { - targetPath = target.toString() - } + // var targetPath: String? = nil + // if let target = account.getLinkTarget(path) { + // targetPath = target.toString() + // } - let item = Item( - address: address, - path: path.toString(), - type: type, - targetPath: targetPath - ) + // let item = Item( + // address: address, + // path: path.toString(), + // type: type, + // targetPath: targetPath + // ) - items.append(item) - return true - }) + // items.append(item) + // return true + // }) - return items + // return items + return [] } \ No newline at end of file diff --git a/public/scripts/storage/get_private_paths.cdc b/public/scripts/storage/get_private_paths.cdc index ed03d41..5a1874f 100644 --- a/public/scripts/storage/get_private_paths.cdc +++ b/public/scripts/storage/get_private_paths.cdc @@ -1,14 +1,15 @@ -pub fun main(address: Address): [PrivatePath] { - __OUTDATED_PATHS__ +access(all) fun main(address: Address): [PrivatePath] { + // __OUTDATED_PATHS__ - let account = getAuthAccount(address) - let cleandPaths: [PrivatePath] = [] - for path in account.privatePaths { - if (outdatedPaths.containsKey(path)) { - continue - } + // let account = getAuthAccount(address) + // let cleandPaths: [PrivatePath] = [] + // for path in account.privatePaths { + // if (outdatedPaths.containsKey(path)) { + // continue + // } - cleandPaths.append(path) - } - return cleandPaths + // cleandPaths.append(path) + // } + // return cleandPaths + return [] } \ No newline at end of file diff --git a/public/scripts/storage/get_public_item.cdc b/public/scripts/storage/get_public_item.cdc index 64fef11..4223479 100644 --- a/public/scripts/storage/get_public_item.cdc +++ b/public/scripts/storage/get_public_item.cdc @@ -1,13 +1,13 @@ // A workaround method -import FungibleToken from 0xFungibleToken -import NonFungibleToken from 0xNonFungibleToken +import "FungibleToken" +import "NonFungibleToken" -pub struct Item { - pub let address: Address - pub let path: String - pub let type: Type +access(all) struct Item { + access(all) let address: Address + access(all) let path: String + access(all) let type: Type - pub let targetPath: String? + access(all) let targetPath: String? init( address: Address, @@ -22,19 +22,21 @@ pub struct Item { } } -pub fun main(address: Address, pathMap: {String: Bool}): [Item] { - let account = getAuthAccount(address) +access(all) fun main(address: Address, pathMap: {String: Bool}): [Item] { + let account = getAuthAccount(address) let items: [Item] = [] - account.forEachPublic(fun (path: PublicPath, type: Type): Bool { + account.storage.forEachPublic(fun (path: PublicPath, type: Type): Bool { if !pathMap.containsKey(path.toString()) { return true } var targetPath: String? = nil - if let target = account.getLinkTarget(path) { - targetPath = target.toString() + // FIXME: This is a workaround to check if the path is a capability + // There is no getLinkTarget method anymore + if account.capabilities.exists(path) { + targetPath = path.toString() } let item = Item( diff --git a/public/scripts/storage/get_public_items.cdc b/public/scripts/storage/get_public_items.cdc index c595228..4708381 100644 --- a/public/scripts/storage/get_public_items.cdc +++ b/public/scripts/storage/get_public_items.cdc @@ -1,18 +1,18 @@ -import FungibleToken from 0xFungibleToken -import NonFungibleToken from 0xNonFungibleToken +import "FungibleToken" +import "NonFungibleToken" -pub struct Item { - pub let address: Address - pub let path: String - pub let type: Type +access(all) struct Item { + access(all) let address: Address + access(all) let path: String + access(all) let type: Type - pub let targetPath: String? + access(all) let targetPath: String? - pub let isCollectionCap: Bool - pub let tokenIDs: [UInt64] + access(all) let isCollectionCap: Bool + access(all) let tokenIDs: [UInt64] - pub let isBalanceCap: Bool - pub let balance: UFix64? + access(all) let isBalanceCap: Bool + access(all) let balance: UFix64? init( address: Address, @@ -35,14 +35,14 @@ pub struct Item { } } -pub fun main(address: Address, pathMap: {String: Bool}): [Item] { - let account = getAuthAccount(address) +access(all) fun main(address: Address, pathMap: {String: Bool}): [Item] { + let account = getAuthAccount(address) let items: [Item] = [] - let balanceCapType = Type>() - let collectionType = Type>() + let balanceCapType = Type>() + let collectionType = Type>() - account.forEachPublic(fun (path: PublicPath, type: Type): Bool { + account.storage.forEachPublic(fun (path: PublicPath, type: Type): Bool { if !pathMap.containsKey(path.toString()) { return true } @@ -53,15 +53,17 @@ pub fun main(address: Address, pathMap: {String: Bool}): [Item] { var tokenIDs: [UInt64] = [] var balance: UFix64? = nil - if let target = account.getLinkTarget(path) { - targetPath = target.toString() + // FIXME: This is a workaround to check if the path is a capability + // There is no getLinkTarget method anymore + if account.capabilities.exists(path) { + targetPath = path.toString() } if (type.isSubtype(of: balanceCapType)) { isBalanceCap = true let vaultRef = account - .getCapability(path) - .borrow<&{FungibleToken.Balance}>() + .capabilities.get<&{FungibleToken.Balance}>(path) + .borrow() if let vault = vaultRef { balance = vault.balance @@ -69,8 +71,8 @@ pub fun main(address: Address, pathMap: {String: Bool}): [Item] { } else if (type.isSubtype(of: collectionType)) { isCollectionCap = true let collectionRef = account - .getCapability(path) - .borrow<&{NonFungibleToken.CollectionPublic}>() + .capabilities.get<&{NonFungibleToken.CollectionPublic}>(path) + .borrow() if let collection = collectionRef { tokenIDs = collection.getIDs() diff --git a/public/scripts/storage/get_public_paths.cdc b/public/scripts/storage/get_public_paths.cdc index 329b225..3db3853 100644 --- a/public/scripts/storage/get_public_paths.cdc +++ b/public/scripts/storage/get_public_paths.cdc @@ -1,9 +1,9 @@ -pub fun main(address: Address): [PublicPath] { +access(all) fun main(address: Address): [PublicPath] { __OUTDATED_PATHS__ - let account = getAuthAccount(address) + let account = getAuthAccount(address) let cleandPaths: [PublicPath] = [] - for path in account.publicPaths { + for path in account.storage.publicPaths { if (outdatedPaths.containsKey(path)) { continue } diff --git a/public/scripts/storage/get_storage_paths.cdc b/public/scripts/storage/get_storage_paths.cdc index f5d8eb9..3f13ace 100644 --- a/public/scripts/storage/get_storage_paths.cdc +++ b/public/scripts/storage/get_storage_paths.cdc @@ -1,9 +1,9 @@ -pub fun main(address: Address): [StoragePath] { +access(all) fun main(address: Address): [StoragePath] { __OUTDATED_PATHS__ - let account = getAuthAccount(address) + let account = getAuthAccount(address) let cleandPaths: [StoragePath] = [] - for path in account.storagePaths { + for path in account.storage.storagePaths { if (outdatedPaths.containsKey(path)) { continue } diff --git a/public/scripts/storage/get_stored_items.cdc b/public/scripts/storage/get_stored_items.cdc index d069c94..44764f4 100644 --- a/public/scripts/storage/get_stored_items.cdc +++ b/public/scripts/storage/get_stored_items.cdc @@ -1,10 +1,11 @@ -import FungibleToken from 0xFungibleToken -import NonFungibleToken from 0xNonFungibleToken -import MetadataViews from 0xMetadataViews +import "FungibleToken" +import "NonFungibleToken" +import "MetadataViews" +import "ViewResolver" -pub struct CollectionDisplay { - pub let name: String - pub let squareImage: MetadataViews.Media +access(all) struct CollectionDisplay { + access(all) let name: String + access(all) let squareImage: MetadataViews.Media init(name: String, squareImage: MetadataViews.Media) { self.name = name @@ -12,9 +13,9 @@ pub struct CollectionDisplay { } } -pub struct CollectionData { - pub let publicPath: PublicPath - pub let storagePath: StoragePath +access(all) struct CollectionData { + access(all) let publicPath: PublicPath + access(all) let storagePath: StoragePath init(publicPath: PublicPath, storagePath: StoragePath) { self.publicPath = publicPath @@ -22,17 +23,17 @@ pub struct CollectionData { } } -pub struct Item { - pub let address: Address - pub let path: String - pub let type: Type - pub let isResource: Bool - pub let isNFTCollection: Bool - pub let display: CollectionDisplay? - pub let collectionData: CollectionData? - pub let tokenIDs: [UInt64] - pub let isVault: Bool - pub let balance: UFix64? +access(all) struct Item { + access(all) let address: Address + access(all) let path: String + access(all) let type: Type + access(all) let isResource: Bool + access(all) let isNFTCollection: Bool + access(all) let display: CollectionDisplay? + access(all) let collectionData: CollectionData? + access(all) let tokenIDs: [UInt64] + access(all) let isVault: Bool + access(all) let balance: UFix64? init(address: Address, path: String, type: Type, isResource: Bool, isNFTCollection: Bool, display: CollectionDisplay?, collectionData: CollectionData?, @@ -50,18 +51,18 @@ pub struct Item { } } -pub fun main(address: Address, pathIdentifiers: [String]): [Item] { - let account = getAuthAccount(address) +access(all) fun main(address: Address, pathIdentifiers: [String]): [Item] { + let account = getAuthAccount(address) let resourceType = Type<@AnyResource>() - let vaultType = Type<@FungibleToken.Vault>() - let collectionType = Type<@NonFungibleToken.Collection>() - let metadataViewType = Type<@AnyResource{MetadataViews.ResolverCollection}>() + let vaultType = Type<@{FungibleToken.Vault}>() + let collectionType = Type<@{NonFungibleToken.Collection}>() + let metadataViewType = Type<@{ViewResolver.ResolverCollection}>() let items: [Item] = [] for identifier in pathIdentifiers { let path = StoragePath(identifier: identifier)! - if let type = account.type(at: path) { + if let type = account.storage.type(at: path) { let isResource = type.isSubtype(of: resourceType) let isNFTCollection = type.isSubtype(of: collectionType) let conformedMetadataViews = type.isSubtype(of: metadataViewType) @@ -70,7 +71,7 @@ pub fun main(address: Address, pathIdentifiers: [String]): [Item] { var collectionDisplay: CollectionDisplay? = nil var collectionData: CollectionData? = nil if isNFTCollection && conformedMetadataViews { - if let collectionRef = account.borrow<&{MetadataViews.ResolverCollection, NonFungibleToken.CollectionPublic}>(from: path) { + if let collectionRef = account.storage.borrow<&{NonFungibleToken.Collection}>(from: path) { tokenIDs = collectionRef.getIDs() // TODO: move to a list @@ -79,23 +80,24 @@ pub fun main(address: Address, pathIdentifiers: [String]): [Item] { && path != /storage/ARTIFACTPackV3Collection && path != /storage/ARTIFACTV2Collection && path != /storage/ArleeScene { - let resolver = collectionRef.borrowViewResolver(id: tokenIDs[0]) - if let display = MetadataViews.getNFTCollectionDisplay(resolver) { - collectionDisplay = CollectionDisplay( - name: display.name, - squareImage: display.squareImage - ) - } - if let data = MetadataViews.getNFTCollectionData(resolver) { - collectionData = CollectionData( - publicPath: data.publicPath, - storagePath: data.storagePath + if let resolver = collectionRef.borrowViewResolver(id: tokenIDs[0]) { + if let display = MetadataViews.getNFTCollectionDisplay(resolver) { + collectionDisplay = CollectionDisplay( + name: display.name, + squareImage: display.squareImage ) + } + if let data = MetadataViews.getNFTCollectionData(resolver) { + collectionData = CollectionData( + publicPath: data.publicPath, + storagePath: data.storagePath + ) + } } } } } else if isNFTCollection { - if let collectionRef = account.borrow<&NonFungibleToken.Collection>(from: path) { + if let collectionRef = account.storage.borrow<&{NonFungibleToken.Collection}>(from: path) { tokenIDs = collectionRef.getIDs() } } @@ -103,7 +105,7 @@ pub fun main(address: Address, pathIdentifiers: [String]): [Item] { let isVault = type.isSubtype(of: vaultType) var balance: UFix64? = nil if isVault { - if let vaultRef = account.borrow<&FungibleToken.Vault>(from: path) { + if let vaultRef = account.storage.borrow<&{FungibleToken.Vault}>(from: path) { balance = vaultRef.balance } } diff --git a/public/scripts/storage/get_stored_resource.cdc b/public/scripts/storage/get_stored_resource.cdc index 5a51e42..b9b5a34 100644 --- a/public/scripts/storage/get_stored_resource.cdc +++ b/public/scripts/storage/get_stored_resource.cdc @@ -1,5 +1,5 @@ -pub fun main(address: Address, pathStr: String): &AnyResource? { - let account = getAuthAccount(address) +access(all) fun main(address: Address, pathStr: String): &AnyResource? { + let account = getAuthAccount(address) let path = StoragePath(identifier: pathStr)! - return account.borrow<&AnyResource>(from: path) + return account.storage.borrow<&AnyResource>(from: path) } \ No newline at end of file diff --git a/public/scripts/storage/get_stored_struct.cdc b/public/scripts/storage/get_stored_struct.cdc index d8ba02b..b1d4d96 100644 --- a/public/scripts/storage/get_stored_struct.cdc +++ b/public/scripts/storage/get_stored_struct.cdc @@ -1,5 +1,5 @@ -pub fun main(address: Address, pathStr: String): &AnyStruct? { - let account = getAuthAccount(address) +access(all) fun main(address: Address, pathStr: String): &AnyStruct? { + let account = getAuthAccount(address) let path = StoragePath(identifier: pathStr)! - return account.borrow<&AnyStruct>(from: path) + return account.storage.borrow<&AnyStruct>(from: path) } \ No newline at end of file diff --git a/public/scripts/storefront/get_existing_listings.cdc b/public/scripts/storefront/get_existing_listings.cdc index 37392f0..8e65b18 100644 --- a/public/scripts/storefront/get_existing_listings.cdc +++ b/public/scripts/storefront/get_existing_listings.cdc @@ -4,12 +4,12 @@ import __NFT_CONTRACT_NAME__ from __NFT_CONTRACT_ADDRESS__ import FTRegistry from 0x097bafa4e0b48eef import FlowToken from 0x1654653399040a61 -pub struct Item { - pub let listingResourceId: UInt64 - pub let details: NFTStorefrontV2.ListingDetails - pub let isGhosted: Bool - pub let isPurchased: Bool - pub let isExpired: Bool +access(all) struct Item { + access(all) let listingResourceId: UInt64 + access(all) let details: NFTStorefrontV2.ListingDetails + access(all) let isGhosted: Bool + access(all) let isPurchased: Bool + access(all) let isExpired: Bool init( listingResourceId: UInt64, @@ -27,7 +27,7 @@ pub struct Item { } // FlowToken only -pub fun main(account: Address, nftID: UInt64): [Item] { +access(all) fun main(account: Address, nftID: UInt64): [Item] { let storefrontRef = getAccount(account) .getCapability<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic}>( NFTStorefrontV2.StorefrontPublicPath diff --git a/public/scripts/storefront/get_listings.cdc b/public/scripts/storefront/get_listings.cdc index 21b2bab..5148479 100644 --- a/public/scripts/storefront/get_listings.cdc +++ b/public/scripts/storefront/get_listings.cdc @@ -3,9 +3,9 @@ import NonFungibleToken from 0x1d7e57aa55817448 import MetadataViews from 0x1d7e57aa55817448 import FTRegistry from 0x097bafa4e0b48eef -pub struct FTInfo { - pub let symbol: String - pub let icon: String? +access(all) struct FTInfo { + access(all) let symbol: String + access(all) let icon: String? init(symbol: String, icon: String?) { self.symbol = symbol @@ -13,10 +13,10 @@ pub struct FTInfo { } } -pub struct CollectionData { - pub let storagePath: StoragePath - pub let publicPath: PublicPath - pub let providerPath: PrivatePath +access(all) struct CollectionData { + access(all) let storagePath: StoragePath + access(all) let publicPath: PublicPath + access(all) let providerPath: PrivatePath init( storagePath: StoragePath, @@ -29,9 +29,9 @@ pub struct CollectionData { } } -pub struct Listings { - pub let validItems: [Item] - pub let invalidItems: [Item] +access(all) struct Listings { + access(all) let validItems: [Item] + access(all) let invalidItems: [Item] init(validItems: [Item], invalidItems: [Item]) { self.validItems = validItems @@ -39,18 +39,18 @@ pub struct Listings { } } -pub struct Item { - pub let listingResourceId: UInt64 - pub let details: NFTStorefrontV2.ListingDetails - pub let isGhosted: Bool - pub let isPurchased: Bool - pub let isExpired: Bool - pub let nft: &NonFungibleToken.NFT? - pub let paymentTokenInfo: FTInfo? - pub let conformMetadataViews: Bool - pub let collectionData: AnyStruct? - pub let display: AnyStruct? - pub let rarity: AnyStruct? +access(all) struct Item { + access(all) let listingResourceId: UInt64 + access(all) let details: NFTStorefrontV2.ListingDetails + access(all) let isGhosted: Bool + access(all) let isPurchased: Bool + access(all) let isExpired: Bool + access(all) let nft: &NonFungibleToken.NFT? + access(all) let paymentTokenInfo: FTInfo? + access(all) let conformMetadataViews: Bool + access(all) let collectionData: AnyStruct? + access(all) let display: AnyStruct? + access(all) let rarity: AnyStruct? init( listingResourceId: UInt64, @@ -79,7 +79,7 @@ pub struct Item { } } -pub fun main(account: Address): Listings { +access(all) fun main(account: Address): Listings { let storefrontRef = getAccount(account) .getCapability<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic}>( NFTStorefrontV2.StorefrontPublicPath diff --git a/public/scripts/switchboard/get_switchboard.cdc b/public/scripts/switchboard/get_switchboard.cdc index 460e1a5..408ba5b 100644 --- a/public/scripts/switchboard/get_switchboard.cdc +++ b/public/scripts/switchboard/get_switchboard.cdc @@ -1,19 +1,26 @@ -import FungibleTokenSwitchboard from 0xFungibleTokenSwitchboard -import FungibleToken from 0xFungibleToken +import "FungibleTokenSwitchboard" +import "FungibleToken" -pub struct SwitchboardInfo { - pub let vaultTypes: [Type] +access(all) struct SwitchboardInfo { + access(all) let vaultTypes: [Type] init(vaultTypes: [Type]) { self.vaultTypes = vaultTypes } } -pub fun main(address: Address): SwitchboardInfo? { - let account = getAuthAccount(address) - if let board = account.borrow<&FungibleTokenSwitchboard.Switchboard>(from: FungibleTokenSwitchboard.StoragePath) { - let types = board.getVaultTypes() - return SwitchboardInfo(vaultTypes: types) +access(all) fun main(address: Address): SwitchboardInfo? { + let account = getAuthAccount(address) + if let board = account.storage.borrow<&FungibleTokenSwitchboard.Switchboard>(from: FungibleTokenSwitchboard.StoragePath) { + let types = board.getSupportedVaultTypes() + let supportedTypes: [Type] = [] + types.forEachKey(fun (key: Type): Bool { + if types[key] == true { + supportedTypes.append(key) + } + return true + }) + return SwitchboardInfo(vaultTypes: supportedTypes) } return nil } \ No newline at end of file diff --git a/public/transactions/bookmark/account/add_or_edit_bookmark.cdc b/public/transactions/bookmark/account/add_or_edit_bookmark.cdc index 2a17c4a..67a63d5 100644 --- a/public/transactions/bookmark/account/add_or_edit_bookmark.cdc +++ b/public/transactions/bookmark/account/add_or_edit_bookmark.cdc @@ -1,23 +1,22 @@ -import FlowviewAccountBookmark from 0xFlowviewAccountBookmark +import "FlowviewAccountBookmark" transaction( address: Address, note: String ) { - let bookmarkCollection: &FlowviewAccountBookmark.AccountBookmarkCollection + let bookmarkCollection: auth(FlowviewAccountBookmark.Manage) &FlowviewAccountBookmark.AccountBookmarkCollection - prepare(signer: AuthAccount) { - if signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { + prepare(signer: auth(Storage, Capabilities) &Account) { + if signer.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { let collection <- FlowviewAccountBookmark.createEmptyCollection() - signer.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.storage.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) - let cap = signer.link<&FlowviewAccountBookmark.AccountBookmarkCollection{FlowviewAccountBookmark.CollectionPublic}>( - FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath, - target: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath - ) ?? panic("Could not create public capability") + let cap = signer.capabilities.storage.issue<&FlowviewAccountBookmark.AccountBookmarkCollection>(FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.capabilities.publish(cap, at: FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath) } - self.bookmarkCollection = signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + self.bookmarkCollection = signer.storage + .borrow(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow collection") } diff --git a/public/transactions/bookmark/account/remove_bookmark.cdc b/public/transactions/bookmark/account/remove_bookmark.cdc index 9b97cd0..4f53a86 100644 --- a/public/transactions/bookmark/account/remove_bookmark.cdc +++ b/public/transactions/bookmark/account/remove_bookmark.cdc @@ -1,20 +1,19 @@ -import FlowviewAccountBookmark from 0xFlowviewAccountBookmark +import "FlowviewAccountBookmark" transaction(address: Address) { - let bookmarkCollection: &FlowviewAccountBookmark.AccountBookmarkCollection + let bookmarkCollection: auth(FlowviewAccountBookmark.Manage) &FlowviewAccountBookmark.AccountBookmarkCollection - prepare(signer: AuthAccount) { - if signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { + prepare(signer: auth(Storage, Capabilities) &Account) { + if signer.storage.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) == nil { let collection <- FlowviewAccountBookmark.createEmptyCollection() - signer.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.storage.save(<-collection, to: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) - let cap = signer.link<&FlowviewAccountBookmark.AccountBookmarkCollection{FlowviewAccountBookmark.CollectionPublic}>( - FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath, - target: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath - ) ?? panic("Could not create public capability") + let cap = signer.capabilities.storage.issue<&FlowviewAccountBookmark.AccountBookmarkCollection>(FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + signer.capabilities.publish(cap, at: FlowviewAccountBookmark.AccountBookmarkCollectionPublicPath) } - self.bookmarkCollection = signer.borrow<&FlowviewAccountBookmark.AccountBookmarkCollection>(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) + self.bookmarkCollection = signer.storage + .borrow(from: FlowviewAccountBookmark.AccountBookmarkCollectionStoragePath) ?? panic("Could not borrow collection") } diff --git a/public/transactions/collection/bulk_transfer_nft.cdc b/public/transactions/collection/bulk_transfer_nft.cdc index 779af52..c7c316e 100644 --- a/public/transactions/collection/bulk_transfer_nft.cdc +++ b/public/transactions/collection/bulk_transfer_nft.cdc @@ -1,19 +1,19 @@ -import NonFungibleToken from 0xNonFungibleToken +import "NonFungibleToken" transaction(recipients: [Address], tokenIds: [UInt64]) { - let senderCollection: &NonFungibleToken.Collection + let senderCollection: auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection} - prepare(account: AuthAccount) { + prepare(account: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { assert(recipients.length == tokenIds.length, message: "invalid input") - self.senderCollection = account.borrow<&NonFungibleToken.Collection>(from: __NFT_STORAGE_PATH__)! + self.senderCollection = account.storage.borrow(from: __NFT_STORAGE_PATH__)! } execute { for index, tokenId in tokenIds { - let recipient = recipients[index]! + let recipient = recipients[index] let recipientAccount = getAccount(recipient) - let recipientCollection = recipientAccount.getCapability<&{NonFungibleToken.CollectionPublic}>(__NFT_PUBLIC_PATH__).borrow() + let recipientCollection = recipientAccount.capabilities.get<&{NonFungibleToken.CollectionPublic}>(__NFT_PUBLIC_PATH__).borrow() ?? panic("Could not borrow capability from recipient") let nft <- self.senderCollection.withdraw(withdrawID: tokenId) diff --git a/public/transactions/collection/transfer_nft.cdc b/public/transactions/collection/transfer_nft.cdc index f9b6c35..7e20481 100644 --- a/public/transactions/collection/transfer_nft.cdc +++ b/public/transactions/collection/transfer_nft.cdc @@ -1,15 +1,15 @@ -import NonFungibleToken from 0xNonFungibleToken +import "NonFungibleToken" transaction(address: Address, tokenId: UInt64) { - let senderCollection: &NonFungibleToken.Collection + let senderCollection: auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection} let receiverCollection: Capability<&{NonFungibleToken.CollectionPublic}> - prepare(account: AuthAccount) { - self.senderCollection = account.borrow<&NonFungibleToken.Collection>(from: __NFT_STORAGE_PATH__)! + prepare(account: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + self.senderCollection = account.storage.borrow(from: __NFT_STORAGE_PATH__)! let receiverAccount = getAccount(address) - self.receiverCollection = receiverAccount.getCapability<&{NonFungibleToken.CollectionPublic}>(__NFT_PUBLIC_PATH__) + self.receiverCollection = receiverAccount.capabilities.get<&{NonFungibleToken.Collection}>(__NFT_PUBLIC_PATH__) } execute { diff --git a/public/transactions/hc/accept_ownership.cdc b/public/transactions/hc/accept_ownership.cdc index cc11f95..0ef08c0 100644 --- a/public/transactions/hc/accept_ownership.cdc +++ b/public/transactions/hc/accept_ownership.cdc @@ -1,19 +1,42 @@ #allowAccountLinking -import HybridCustody from 0xHybridCustody -import MetadataViews from 0xMetadataViews +import "HybridCustody" +import "CapabilityFilter" +import "ViewResolver" + +transaction(childAddress: Address, filterAddress: Address?, filterPath: PublicPath?) { + prepare(acct: auth(Storage, Capabilities, Inbox) &Account) { + var filter: Capability<&{CapabilityFilter.Filter}>? = nil + if filterAddress != nil && filterPath != nil { + filter = getAccount(filterAddress!).capabilities.get<&{CapabilityFilter.Filter}>(filterPath!) + } + + if acct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { + let m <- HybridCustody.createManager(filter: filter) + acct.storage.save(<- m, to: HybridCustody.ManagerStoragePath) + + for c in acct.capabilities.storage.getControllers(forPath: HybridCustody.ManagerStoragePath) { + c.delete() + } + + acct.capabilities.unpublish(HybridCustody.ManagerPublicPath) + + acct.capabilities.storage.issue(HybridCustody.ManagerStoragePath) + acct.capabilities.publish( + acct.capabilities.storage.issue<&{HybridCustody.ManagerPublic}>(HybridCustody.ManagerStoragePath), + at: HybridCustody.ManagerPublicPath + ) + } -transaction(childAddress: Address) { - prepare(acct: AuthAccount) { let inboxName = HybridCustody.getOwnerIdentifier(acct.address) - let cap = acct.inbox.claim<&AnyResource{HybridCustody.OwnedAccountPrivate, HybridCustody.OwnedAccountPublic, MetadataViews.Resolver}>(inboxName, provider: childAddress) + let cap = acct.inbox.claim(inboxName, provider: childAddress) ?? panic("owned account cap not found") - let manager = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) + let manager = acct.storage.borrow(from: HybridCustody.ManagerStoragePath) ?? panic("manager no found") + let ownedAcct = cap.borrow() ?? panic("could not borrow owned account capability") + manager.addOwnedAccount(cap: cap) } - - execute {} } \ No newline at end of file diff --git a/public/transactions/hc/publish_to_parent.cdc b/public/transactions/hc/publish_to_parent.cdc index 8d1b871..0ed5428 100644 --- a/public/transactions/hc/publish_to_parent.cdc +++ b/public/transactions/hc/publish_to_parent.cdc @@ -1,17 +1,18 @@ -import HybridCustody from 0xHybridCustody -import CapabilityFactory from 0xCapabilityFactory -import CapabilityFilter from 0xCapabilityFilter -import CapabilityDelegator from 0xCapabilityDelegator +import "HybridCustody" +import "CapabilityFactory" +import "CapabilityFilter" +import "CapabilityDelegator" +import "ViewResolver" transaction(parent: Address, factoryAddress: Address, filterAddress: Address) { - prepare(acct: AuthAccount) { - let owned = acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + let owned = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned account not found") - let factory = getAccount(factoryAddress).getCapability<&CapabilityFactory.Manager{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath) + let factory = getAccount(factoryAddress).capabilities.get<&CapabilityFactory.Manager>(CapabilityFactory.PublicPath) assert(factory.check(), message: "factory address is not configured properly") - let filter = getAccount(filterAddress).getCapability<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) + let filter = getAccount(filterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) assert(filter.check(), message: "capability filter is not configured properly") owned.publishToParent(parentAddress: parent, factory: factory, filter: filter) diff --git a/public/transactions/hc/redeem_account.cdc b/public/transactions/hc/redeem_account.cdc index c0aca1e..82a757e 100644 --- a/public/transactions/hc/redeem_account.cdc +++ b/public/transactions/hc/redeem_account.cdc @@ -1,17 +1,41 @@ -import MetadataViews from 0xMetadataViews -import HybridCustody from 0xHybridCustody +import "MetadataViews" +import "ViewResolver" + +import "HybridCustody" +import "CapabilityFilter" + +transaction(childAddress: Address, filterAddress: Address?, filterPath: PublicPath?) { + prepare(acct: auth(Storage, Capabilities, Inbox) &Account) { + var filter: Capability<&{CapabilityFilter.Filter}>? = nil + if filterAddress != nil && filterPath != nil { + filter = getAccount(filterAddress!).capabilities.get<&{CapabilityFilter.Filter}>(filterPath!) + } + + if acct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { + let m <- HybridCustody.createManager(filter: filter) + acct.storage.save(<- m, to: HybridCustody.ManagerStoragePath) + + for c in acct.capabilities.storage.getControllers(forPath: HybridCustody.ManagerStoragePath) { + c.delete() + } + + acct.capabilities.unpublish(HybridCustody.ManagerPublicPath) + + acct.capabilities.publish( + acct.capabilities.storage.issue<&{HybridCustody.ManagerPublic}>(HybridCustody.ManagerStoragePath), + at: HybridCustody.ManagerPublicPath + ) + + acct.capabilities.storage.issue(HybridCustody.ManagerStoragePath) + } -transaction(childAddress: Address) { - prepare(acct: AuthAccount) { let inboxName = HybridCustody.getChildAccountIdentifier(acct.address) - let cap = acct.inbox.claim<&HybridCustody.ChildAccount{HybridCustody.AccountPrivate, HybridCustody.AccountPublic, MetadataViews.Resolver}>(inboxName, provider: childAddress) + let cap = acct.inbox.claim(inboxName, provider: childAddress) ?? panic("child account cap not found") - let manager = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) + let manager = acct.storage.borrow(from: HybridCustody.ManagerStoragePath) ?? panic("manager no found") manager.addAccount(cap: cap) } - - execute {} } \ No newline at end of file diff --git a/public/transactions/hc/remove_child_account.cdc b/public/transactions/hc/remove_child_account.cdc index 2ee3188..285fb33 100644 --- a/public/transactions/hc/remove_child_account.cdc +++ b/public/transactions/hc/remove_child_account.cdc @@ -1,9 +1,9 @@ -import HybridCustody from 0xHybridCustody +import "HybridCustody" transaction(child: Address) { - prepare (acct: AuthAccount) { - let manager = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) - ?? panic("manager not found") + prepare (acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + let manager = acct.storage.borrow(from: HybridCustody.ManagerStoragePath) + ?? panic("manager no found") manager.removeChild(addr: child) } } \ No newline at end of file diff --git a/public/transactions/hc/remove_parent_from_child.cdc b/public/transactions/hc/remove_parent_from_child.cdc index 94a1628..5b57b7c 100644 --- a/public/transactions/hc/remove_parent_from_child.cdc +++ b/public/transactions/hc/remove_parent_from_child.cdc @@ -1,13 +1,13 @@ -import HybridCustody from 0xHybridCustody +import "HybridCustody" transaction(parent: Address) { - prepare(acct: AuthAccount) { - let owned = acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) + prepare(acct: auth(Storage) &Account) { + let owned = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned not found") owned.removeParent(parent: parent) - let manager = getAccount(parent).getCapability<&HybridCustody.Manager{HybridCustody.ManagerPublic}>(HybridCustody.ManagerPublicPath) + let manager = getAccount(parent).capabilities.get<&{HybridCustody.ManagerPublic}>(HybridCustody.ManagerPublicPath) .borrow() ?? panic("manager not found") let children = manager.getChildAddresses() assert(!children.contains(acct.address), message: "removed child is still in manager resource") diff --git a/public/transactions/hc/set_manager_capability_filter.cdc b/public/transactions/hc/set_manager_capability_filter.cdc index dd7da61..487791a 100644 --- a/public/transactions/hc/set_manager_capability_filter.cdc +++ b/public/transactions/hc/set_manager_capability_filter.cdc @@ -1,12 +1,12 @@ -import HybridCustody from 0xHybridCustody -import CapabilityFilter from 0xCapabilityFilter +import "HybridCustody" +import "CapabilityFilter" transaction(childAddress: Address, filterAddress: Address) { - prepare(acct: AuthAccount) { - let m = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + let m = acct.storage.borrow(from: HybridCustody.ManagerStoragePath) ?? panic("manager not found") - let filter = getAccount(filterAddress).getCapability<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) + let filter = getAccount(filterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) assert(filter.check(), message: "capability filter is not configured properly") m.setManagerCapabilityFilter(cap: filter, childAddress: childAddress) diff --git a/public/transactions/hc/setup_child_display.cdc b/public/transactions/hc/setup_child_display.cdc index fda6d03..57078b8 100644 --- a/public/transactions/hc/setup_child_display.cdc +++ b/public/transactions/hc/setup_child_display.cdc @@ -1,9 +1,9 @@ -import HybridCustody from 0xHybridCustody -import MetadataViews from 0xMetadataViews +import "HybridCustody" +import "MetadataViews" transaction(childAddress: Address, name: String?, desc: String?, thumbnailURL: String?) { - prepare(acct: AuthAccount) { - let m = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + let m = acct.storage.borrow(from: HybridCustody.ManagerStoragePath) ?? panic("manager not found") if name != nil && desc != nil && thumbnailURL != nil { diff --git a/public/transactions/hc/setup_hc_manager.cdc b/public/transactions/hc/setup_hc_manager.cdc index cccce3d..4771ec2 100644 --- a/public/transactions/hc/setup_hc_manager.cdc +++ b/public/transactions/hc/setup_hc_manager.cdc @@ -1,24 +1,30 @@ -import HybridCustody from 0xHybridCustody -import CapabilityFilter from 0xCapabilityFilter +import "HybridCustody" +import "CapabilityFilter" -transaction(filterAddress: Address?, filterPath: String?) { - prepare(acct: AuthAccount) { +transaction(filterAddress: Address?, filterPath: PublicPath?) { + prepare(acct: auth(Storage, Capabilities) &Account) { var filter: Capability<&{CapabilityFilter.Filter}>? = nil if filterAddress != nil && filterPath != nil { - let path = PublicPath(identifier: filterPath!) - filter = getAccount(filterAddress!).getCapability<&{CapabilityFilter.Filter}>(path!) + filter = getAccount(filterAddress!).capabilities.get<&{CapabilityFilter.Filter}>(filterPath!) } - if acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { + if acct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { let m <- HybridCustody.createManager(filter: filter) - acct.save(<- m, to: HybridCustody.ManagerStoragePath) + acct.storage.save(<- m, to: HybridCustody.ManagerStoragePath) } + + for c in acct.capabilities.storage.getControllers(forPath: HybridCustody.ManagerStoragePath) { + c.delete() + } + + acct.capabilities.unpublish(HybridCustody.ManagerPublicPath) - acct.unlink(HybridCustody.ManagerPublicPath) - acct.unlink(HybridCustody.ManagerPrivatePath) + acct.capabilities.publish( + acct.capabilities.storage.issue<&{HybridCustody.ManagerPublic}>(HybridCustody.ManagerStoragePath), + at: HybridCustody.ManagerPublicPath + ) - acct.link<&HybridCustody.Manager{HybridCustody.ManagerPrivate, HybridCustody.ManagerPublic}>(HybridCustody.ManagerPrivatePath, target: HybridCustody.ManagerStoragePath) - acct.link<&HybridCustody.Manager{HybridCustody.ManagerPublic}>(HybridCustody.ManagerPublicPath, target: HybridCustody.ManagerStoragePath) + acct.capabilities.storage.issue(HybridCustody.ManagerStoragePath) } } \ No newline at end of file diff --git a/public/transactions/hc/setup_owned_account.cdc b/public/transactions/hc/setup_owned_account.cdc index af91916..63815b5 100644 --- a/public/transactions/hc/setup_owned_account.cdc +++ b/public/transactions/hc/setup_owned_account.cdc @@ -1,41 +1,42 @@ #allowAccountLinking -import MetadataViews from 0xMetadataViews - -import HybridCustody from 0xHybridCustody +import "ViewResolver" +import "MetadataViews" +import "HybridCustody" /// This transaction configures an OwnedAccount in the signer if needed and configures its Capabilities per /// HybridCustody's intended design. If Display values are specified (as recommended), they will be set on the /// signer's OwnedAccount. /// transaction(name: String?, desc: String?, thumbnailURL: String?) { - prepare(acct: AuthAccount) { - var acctCap = acct.getCapability<&AuthAccount>(HybridCustody.LinkedAccountPrivatePath) - if !acctCap.check() { - acctCap = acct.linkAccount(HybridCustody.LinkedAccountPrivatePath)! - } + prepare(acct: auth(Storage, Capabilities) &Account) { + let acctCap = acct.capabilities.account.issue() - if acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) == nil { + if acct.storage.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) == nil { let ownedAccount <- HybridCustody.createOwnedAccount(acct: acctCap) - acct.save(<-ownedAccount, to: HybridCustody.OwnedAccountStoragePath) + acct.storage.save(<-ownedAccount, to: HybridCustody.OwnedAccountStoragePath) } - let owned = acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) + let owned = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned account not found") // Set the display metadata for the OwnedAccount if name != nil && desc != nil && thumbnailURL != nil { let thumbnail = MetadataViews.HTTPFile(url: thumbnailURL!) - let display = MetadataViews.Display(name: name!, description: desc!, thumbnail: thumbnail!) + let display = MetadataViews.Display(name: name!, description: desc!, thumbnail: thumbnail) owned.setDisplay(display) } // check that paths are all configured properly - acct.unlink(HybridCustody.OwnedAccountPrivatePath) - acct.link<&HybridCustody.OwnedAccount{HybridCustody.BorrowableAccount, HybridCustody.OwnedAccountPublic, MetadataViews.Resolver}>(HybridCustody.OwnedAccountPrivatePath, target: HybridCustody.OwnedAccountStoragePath) + for c in acct.capabilities.storage.getControllers(forPath: HybridCustody.OwnedAccountStoragePath) { + c.delete() + } - acct.unlink(HybridCustody.OwnedAccountPublicPath) - acct.link<&HybridCustody.OwnedAccount{HybridCustody.OwnedAccountPublic, MetadataViews.Resolver}>(HybridCustody.OwnedAccountPublicPath, target: HybridCustody.OwnedAccountStoragePath) + acct.capabilities.storage.issue<&{HybridCustody.BorrowableAccount, HybridCustody.OwnedAccountPublic, ViewResolver.Resolver}>(HybridCustody.OwnedAccountStoragePath) + acct.capabilities.publish( + acct.capabilities.storage.issue<&{HybridCustody.OwnedAccountPublic, ViewResolver.Resolver}>(HybridCustody.OwnedAccountStoragePath), + at: HybridCustody.OwnedAccountPublicPath + ) } } \ No newline at end of file diff --git a/public/transactions/hc/setup_owned_account_and_publish_to_parent.cdc b/public/transactions/hc/setup_owned_account_and_publish_to_parent.cdc index 4ec6a92..6b9f380 100644 --- a/public/transactions/hc/setup_owned_account_and_publish_to_parent.cdc +++ b/public/transactions/hc/setup_owned_account_and_publish_to_parent.cdc @@ -1,58 +1,59 @@ #allowAccountLinking -import MetadataViews from 0xMetadataViews +import "MetadataViews" +import "ViewResolver" -import HybridCustody from 0xHybridCustody -import CapabilityFactory from 0xCapabilityFactory -import CapabilityFilter from 0xCapabilityFilter -import CapabilityDelegator from 0xCapabilityDelegator +import "HybridCustody" +import "CapabilityFactory" +import "CapabilityFilter" +import "CapabilityDelegator" /// This transaction configures an OwnedAccount in the signer if needed, and proceeds to create a ChildAccount /// using CapabilityFactory.Manager and CapabilityFilter.Filter Capabilities from the given addresses. A /// Capability on the ChildAccount is then published to the specified parent account. /// transaction( - parent: Address, - factoryAddress: Address, - filterAddress: Address, - name: String?, - desc: String?, - thumbnailURL: String? - ) { - - prepare(acct: AuthAccount) { + parent: Address, + factoryAddress: Address, + filterAddress: Address, + name: String?, + desc: String?, + thumbnailURL: String? +) { + prepare(acct: auth(Storage, Capabilities) &Account) { // Configure OwnedAccount if it doesn't exist - if acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) == nil { - var acctCap = acct.getCapability<&AuthAccount>(HybridCustody.LinkedAccountPrivatePath) - if !acctCap.check() { - acctCap = acct.linkAccount(HybridCustody.LinkedAccountPrivatePath)! - } + if acct.storage.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) == nil { + var acctCap = acct.capabilities.account.issue() let ownedAccount <- HybridCustody.createOwnedAccount(acct: acctCap) - acct.save(<-ownedAccount, to: HybridCustody.OwnedAccountStoragePath) + acct.storage.save(<-ownedAccount, to: HybridCustody.OwnedAccountStoragePath) + } + + for c in acct.capabilities.storage.getControllers(forPath: HybridCustody.OwnedAccountStoragePath) { + c.delete() } - // check that paths are all configured properly - acct.unlink(HybridCustody.OwnedAccountPrivatePath) - acct.link<&HybridCustody.OwnedAccount{HybridCustody.BorrowableAccount, HybridCustody.OwnedAccountPublic, MetadataViews.Resolver}>(HybridCustody.OwnedAccountPrivatePath, target: HybridCustody.OwnedAccountStoragePath) - acct.unlink(HybridCustody.OwnedAccountPublicPath) - acct.link<&HybridCustody.OwnedAccount{HybridCustody.OwnedAccountPublic, MetadataViews.Resolver}>(HybridCustody.OwnedAccountPublicPath, target: HybridCustody.OwnedAccountStoragePath) + acct.capabilities.storage.issue<&{HybridCustody.BorrowableAccount, HybridCustody.OwnedAccountPublic, ViewResolver.Resolver}>(HybridCustody.OwnedAccountStoragePath) + acct.capabilities.publish( + acct.capabilities.storage.issue<&{HybridCustody.OwnedAccountPublic, ViewResolver.Resolver}>(HybridCustody.OwnedAccountStoragePath), + at: HybridCustody.OwnedAccountPublicPath + ) - let owned = acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) + let owned = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned account not found") // Set the display metadata for the OwnedAccount if name != nil && desc != nil && thumbnailURL != nil { let thumbnail = MetadataViews.HTTPFile(url: thumbnailURL!) - let display = MetadataViews.Display(name: name!, description: desc!, thumbnail: thumbnail!) + let display = MetadataViews.Display(name: name!, description: desc!, thumbnail: thumbnail) owned.setDisplay(display) } // Get CapabilityFactory & CapabilityFilter Capabilities - let factory = getAccount(factoryAddress).getCapability<&CapabilityFactory.Manager{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath) + let factory = getAccount(factoryAddress).capabilities.get<&CapabilityFactory.Manager>(CapabilityFactory.PublicPath) assert(factory.check(), message: "factory address is not configured properly") - let filter = getAccount(filterAddress).getCapability<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) + let filter = getAccount(filterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) assert(filter.check(), message: "capability filter is not configured properly") // Finally publish a ChildAccount capability on the signing account to the specified parent diff --git a/public/transactions/hc/transfer_ownership.cdc b/public/transactions/hc/transfer_ownership.cdc index 66536f6..34f1a30 100644 --- a/public/transactions/hc/transfer_ownership.cdc +++ b/public/transactions/hc/transfer_ownership.cdc @@ -1,10 +1,10 @@ #allowAccountLinking -import HybridCustody from 0xHybridCustody +import "HybridCustody" transaction(owner: Address) { - prepare(acct: AuthAccount) { - let owned = acct.borrow<&HybridCustody.OwnedAccount>(from: HybridCustody.OwnedAccountStoragePath) + prepare(acct: auth(Storage) &Account) { + let owned = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned not found") owned.giveOwnership(to: owner) } diff --git a/public/transactions/hc/transfer_ownership_from_manager.cdc b/public/transactions/hc/transfer_ownership_from_manager.cdc index f216d17..45a0e3d 100644 --- a/public/transactions/hc/transfer_ownership_from_manager.cdc +++ b/public/transactions/hc/transfer_ownership_from_manager.cdc @@ -1,10 +1,10 @@ #allowAccountLinking -import HybridCustody from 0xHybridCustody +import "HybridCustody" transaction(ownedAddress: Address, owner: Address) { - prepare(acct: AuthAccount) { - let manager = acct.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) + prepare(acct: auth(Storage) &Account) { + let manager = acct.storage.borrow(from: HybridCustody.ManagerStoragePath) ?? panic("manager not found") manager.giveOwnership(addr: ownedAddress, to: owner) } diff --git a/public/transactions/key/create_key.cdc b/public/transactions/key/create_key.cdc index 28774bc..266d85a 100644 --- a/public/transactions/key/create_key.cdc +++ b/public/transactions/key/create_key.cdc @@ -4,7 +4,7 @@ transaction( hashAlgo: UInt8, weight: UFix64 ) { - prepare(signer: AuthAccount) { + prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { let pubkey = PublicKey( publicKey: publicKey.decodeHex(), signatureAlgorithm: SignatureAlgorithm(rawValue: signAlgo)! diff --git a/public/transactions/key/revoke_key.cdc b/public/transactions/key/revoke_key.cdc index e785420..0237810 100644 --- a/public/transactions/key/revoke_key.cdc +++ b/public/transactions/key/revoke_key.cdc @@ -1,5 +1,5 @@ transaction(keyIndex: Int) { - prepare(signer: AuthAccount) { + prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { signer.keys.revoke(keyIndex: keyIndex) } } \ No newline at end of file diff --git a/public/transactions/storage/destroy.cdc b/public/transactions/storage/destroy.cdc index 724f3a6..9dd8937 100644 --- a/public/transactions/storage/destroy.cdc +++ b/public/transactions/storage/destroy.cdc @@ -1,7 +1,9 @@ +import "Burner" + transaction() { - prepare(signer: AuthAccount) { - if let rsc <- signer.load<@AnyResource>(from: __PATH__) { - destroy rsc + prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + if let rsc <- signer.storage.load<@AnyResource>(from: __PATH__) { + Burner.burn(<- rsc) } } } \ No newline at end of file diff --git a/public/transactions/storage/unlink.cdc b/public/transactions/storage/unlink.cdc index 2cdfb1f..55e5b11 100644 --- a/public/transactions/storage/unlink.cdc +++ b/public/transactions/storage/unlink.cdc @@ -1,5 +1,5 @@ transaction() { - prepare(signer: AuthAccount) { - signer.unlink(__PATH__) + prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + signer.capabilities.unpublish(__PATH__) } } \ No newline at end of file diff --git a/public/transactions/storefront/buy_item.cdc b/public/transactions/storefront/buy_item.cdc index 8b2eaae..443596d 100644 --- a/public/transactions/storefront/buy_item.cdc +++ b/public/transactions/storefront/buy_item.cdc @@ -19,7 +19,7 @@ transaction(listingResourceID: UInt64, storefrontAddress: Address, commissionRec let listing: &NFTStorefrontV2.Listing{NFTStorefrontV2.ListingPublic} var commissionRecipientCap: Capability<&{FungibleToken.Receiver}>? - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { self.commissionRecipientCap = nil // Access the storefront public resource of the seller to purchase the listing. self.storefront = getAccount(storefrontAddress) diff --git a/public/transactions/storefront/cleanup_expired.cdc b/public/transactions/storefront/cleanup_expired.cdc index e6aef66..1828660 100644 --- a/public/transactions/storefront/cleanup_expired.cdc +++ b/public/transactions/storefront/cleanup_expired.cdc @@ -3,7 +3,7 @@ import NFTStorefrontV2 from 0xNFTStorefrontV2 transaction(account: Address, from: UInt64, to: UInt64) { let storefrontRef: &NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic} - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { self.storefrontRef = getAccount(account) .getCapability<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic}>( NFTStorefrontV2.StorefrontPublicPath diff --git a/public/transactions/storefront/cleanup_ghosted.cdc b/public/transactions/storefront/cleanup_ghosted.cdc index 713dfbf..be9be2a 100644 --- a/public/transactions/storefront/cleanup_ghosted.cdc +++ b/public/transactions/storefront/cleanup_ghosted.cdc @@ -3,7 +3,7 @@ import NFTStorefrontV2 from 0xNFTStorefrontV2 transaction(account: Address, listingResourceIds: [UInt64]) { let storefrontRef: &NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic} - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { self.storefrontRef = getAccount(account) .getCapability<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic}>( NFTStorefrontV2.StorefrontPublicPath diff --git a/public/transactions/storefront/cleanup_purchased.cdc b/public/transactions/storefront/cleanup_purchased.cdc index c6da8c9..70b5f8e 100644 --- a/public/transactions/storefront/cleanup_purchased.cdc +++ b/public/transactions/storefront/cleanup_purchased.cdc @@ -3,7 +3,7 @@ import NFTStorefrontV2 from 0xNFTStorefrontV2 transaction(account: Address, listingResourceIds: [UInt64]) { let storefrontRef: &NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic} - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { self.storefrontRef = getAccount(account) .getCapability<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic}>( NFTStorefrontV2.StorefrontPublicPath diff --git a/public/transactions/storefront/remove_item.cdc b/public/transactions/storefront/remove_item.cdc index 226bac2..272d6bc 100644 --- a/public/transactions/storefront/remove_item.cdc +++ b/public/transactions/storefront/remove_item.cdc @@ -8,7 +8,7 @@ import NFTStorefrontV2 from 0xNFTStorefrontV2 transaction(listingResourceID: UInt64) { let storefront: &NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontManager} - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { self.storefront = acct.borrow<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontManager}>(from: NFTStorefrontV2.StorefrontStoragePath) ?? panic("Missing or mis-typed NFTStorefrontV2.Storefront") } diff --git a/public/transactions/storefront/sell_item.cdc b/public/transactions/storefront/sell_item.cdc index 1e65687..47e7749 100644 --- a/public/transactions/storefront/sell_item.cdc +++ b/public/transactions/storefront/sell_item.cdc @@ -16,7 +16,7 @@ transaction(saleItemID: UInt64, saleItemPrice: UFix64, days: UInt64) { var saleCuts: [NFTStorefrontV2.SaleCut] var marketplacesCapability: [Capability<&AnyResource{FungibleToken.Receiver}>] - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { if acct.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil { let storefront <- NFTStorefrontV2.createStorefront() as! @NFTStorefrontV2.Storefront acct.save(<-storefront, to: NFTStorefrontV2.StorefrontStoragePath) diff --git a/public/transactions/storefront/setup_account.cdc b/public/transactions/storefront/setup_account.cdc index 756bcb3..e8abdc6 100644 --- a/public/transactions/storefront/setup_account.cdc +++ b/public/transactions/storefront/setup_account.cdc @@ -3,7 +3,7 @@ import NFTStorefrontV2 from 0xNFTStorefrontV2 // This transaction installs the Storefront ressource in an account. transaction { - prepare(acct: AuthAccount) { + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { // If the account doesn't already have a Storefront if acct.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil { diff --git a/public/transactions/switchboard/add_new_vault.cdc b/public/transactions/switchboard/add_new_vault.cdc index e079486..79e878f 100644 --- a/public/transactions/switchboard/add_new_vault.cdc +++ b/public/transactions/switchboard/add_new_vault.cdc @@ -1,18 +1,18 @@ -import FungibleTokenSwitchboard from 0xFungibleTokenSwitchboard -import FungibleToken from 0xFungibleToken +import "FungibleTokenSwitchboard" +import "FungibleToken" transaction { let capability: Capability<&{FungibleToken.Receiver}> - let switchboardRef: &FungibleTokenSwitchboard.Switchboard + let switchboardRef: auth(FungibleTokenSwitchboard.Owner) &FungibleTokenSwitchboard.Switchboard - prepare(signer: AuthAccount) { + prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { self.capability= - signer.getCapability<&{FungibleToken.Receiver}>(__TOKEN_RECEIVER_PATH__) + signer.capabilities.get<&{FungibleToken.Receiver}>(__TOKEN_RECEIVER_PATH__) assert(self.capability.check(), message: "Signer does not have a token receiver capability") - self.switchboardRef = signer.borrow<&FungibleTokenSwitchboard.Switchboard> + self.switchboardRef = signer.storage.borrow (from: FungibleTokenSwitchboard.StoragePath) ?? panic("Could not borrow reference to switchboard") } diff --git a/public/transactions/switchboard/remove_vault.cdc b/public/transactions/switchboard/remove_vault.cdc index 0480f2b..75e0faf 100644 --- a/public/transactions/switchboard/remove_vault.cdc +++ b/public/transactions/switchboard/remove_vault.cdc @@ -1,14 +1,14 @@ -import FungibleTokenSwitchboard from 0xFungibleTokenSwitchboard -import FungibleToken from 0xFungibleToken +import "FungibleTokenSwitchboard" +import "FungibleToken" transaction { let capability: Capability<&{FungibleToken.Receiver}> - let switchboardRef: &FungibleTokenSwitchboard.Switchboard + let switchboardRef: auth(FungibleTokenSwitchboard.Owner) &FungibleTokenSwitchboard.Switchboard - prepare(signer: AuthAccount) { - self.capability = signer.getCapability<&{FungibleToken.Receiver}>(__TOKEN_RECEIVER_PATH__) + prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + self.capability = signer.capabilities.get<&{FungibleToken.Receiver}>(__TOKEN_RECEIVER_PATH__) - self.switchboardRef = signer.borrow<&FungibleTokenSwitchboard.Switchboard> + self.switchboardRef = signer.storage.borrow (from: FungibleTokenSwitchboard.StoragePath) ?? panic("Could not borrow reference to switchboard") } diff --git a/public/transactions/switchboard/setup.cdc b/public/transactions/switchboard/setup.cdc index 3dd3574..cc8f5c5 100644 --- a/public/transactions/switchboard/setup.cdc +++ b/public/transactions/switchboard/setup.cdc @@ -1,22 +1,21 @@ -import FungibleTokenSwitchboard from 0xFungibleTokenSwitchboard -import FungibleToken from 0xFungibleToken +import "FungibleTokenSwitchboard" +import "FungibleToken" transaction { - prepare(acct: AuthAccount) { - if acct.borrow<&FungibleTokenSwitchboard.Switchboard> + prepare(acct: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) { + if acct.storage.borrow<&FungibleTokenSwitchboard.Switchboard> (from: FungibleTokenSwitchboard.StoragePath) == nil { - acct.save( + acct.storage.save( <- FungibleTokenSwitchboard.createSwitchboard(), to: FungibleTokenSwitchboard.StoragePath) - acct.link<&FungibleTokenSwitchboard.Switchboard{FungibleToken.Receiver}>( - FungibleTokenSwitchboard.ReceiverPublicPath, - target: FungibleTokenSwitchboard.StoragePath + acct.capabilities.publish( + acct.capabilities.storage.issue<&{FungibleToken.Receiver}>(FungibleTokenSwitchboard.StoragePath), + at: FungibleTokenSwitchboard.ReceiverPublicPath ) - - acct.link<&FungibleTokenSwitchboard.Switchboard{FungibleTokenSwitchboard.SwitchboardPublic, FungibleToken.Receiver}>( - FungibleTokenSwitchboard.PublicPath, - target: FungibleTokenSwitchboard.StoragePath + acct.capabilities.publish( + acct.capabilities.storage.issue<&FungibleTokenSwitchboard.Switchboard>(FungibleTokenSwitchboard.StoragePath), + at: FungibleTokenSwitchboard.PublicPath ) } }