From 1346ae114f4af393f3ed80d188f1469192c0da9a Mon Sep 17 00:00:00 2001 From: Austin Kline Date: Sat, 4 May 2024 06:55:21 -0700 Subject: [PATCH] sync new nft standard and public capability retrieval changes --- contracts/HybridCustody.cdc | 14 +++++++------- contracts/factories/NFTCollectionFactory.cdc | 17 +++++++---------- .../NFTProviderAndCollectionFactory.cdc | 4 ++-- contracts/factories/NFTProviderFactory.cdc | 4 ++-- contracts/standard/ExampleNFT.cdc | 2 +- contracts/standard/ExampleNFT2.cdc | 2 +- package-lock.json | 8 ++++---- package.json | 2 +- scripts/delegator/find_nft_provider_cap.cdc | 2 +- scripts/delegator/get_all_private_caps.cdc | 2 +- scripts/delegator/get_nft_provider.cdc | 4 ++-- .../factory/get_nft_provider_from_factory.cdc | 4 ++-- .../get_nft_provider_from_factory_allowed.cdc | 6 +++--- .../get_account_public_address.cdc | 1 - .../get_child_account_nft_capabilities.cdc | 4 ++-- .../get_nft_provider_capability.cdc | 2 +- .../get_nft_provider_capability_optional.cdc | 2 +- scripts/test/remove_nft_provider_factory.cdc | 2 +- .../test/test_get_accessible_child_nfts.cdc | 2 +- test/CapabilityDelegator_tests.cdc | 4 ++-- test/CapabilityFactory_tests.cdc | 18 +++++++++--------- .../delegator/add_private_nft_collection.cdc | 2 +- .../remove_private_nft_collection.cdc | 2 +- .../setup_nft_filter_and_factory_manager.cdc | 12 ++++++------ transactions/example-nft-2/mint_to_account.cdc | 2 +- transactions/example-nft-2/setup_full.cdc | 2 +- transactions/example-nft/mint_to_account.cdc | 2 +- transactions/example-nft/setup_full.cdc | 2 +- transactions/factory/setup_empty_factory.cdc | 4 ++-- transactions/factory/setup_ft_manager.cdc | 4 ++-- transactions/factory/setup_nft_ft_manager.cdc | 8 ++++---- transactions/factory/setup_nft_manager.cdc | 6 +++--- transactions/filter/allow/setup.cdc | 2 +- transactions/filter/deny/setup.cdc | 2 +- transactions/filter/setup_allow_all.cdc | 2 +- .../hybrid-custody/accept_ownership.cdc | 1 - ...dd_example_nft2_collection_to_delegator.cdc | 2 +- .../onboarding/blockchain_native.cdc | 1 - .../hybrid-custody/publish_to_parent.cdc | 4 ++-- transactions/hybrid-custody/redeem_account.cdc | 1 - .../remove_parent_from_child.cdc | 2 +- .../set_capability_factory_for_parent.cdc | 1 - .../set_capability_filter_for_parent.cdc | 1 - .../hybrid-custody/set_default_manager_cap.cdc | 1 - .../hybrid-custody/set_manager_filter_cap.cdc | 1 - .../hybrid-custody/setup_multi_sig.cdc | 3 --- ...tup_owned_account_and_publish_to_parent.cdc | 2 -- 47 files changed, 81 insertions(+), 97 deletions(-) diff --git a/contracts/HybridCustody.cdc b/contracts/HybridCustody.cdc index 7866c64..1c0a026 100644 --- a/contracts/HybridCustody.cdc +++ b/contracts/HybridCustody.cdc @@ -298,7 +298,7 @@ access(all) contract HybridCustody { /// Adds a ChildAccount Capability to this Manager. If a default Filter is set in the manager, it will also be /// added to the ChildAccount /// - access(Manage | Insert) fun addAccount(cap: Capability) { + access(Manage) fun addAccount(cap: Capability) { pre { self.childAccounts[cap.address] == nil: "There is already a child account with this address" } @@ -336,7 +336,7 @@ access(all) contract HybridCustody { /// Removes specified child account from the Manager's child accounts. Callbacks to the child account remove /// any associated resources and Capabilities /// - access(Manage | Remove) fun removeChild(addr: Address) { + access(Manage) fun removeChild(addr: Address) { let cap = self.childAccounts.remove(key: addr) ?? panic("child account not found") @@ -370,7 +370,7 @@ access(all) contract HybridCustody { /// Adds an owned account to the Manager's list of owned accounts, setting the Manager account as the owner of /// the given account /// - access(Manage | Insert) fun addOwnedAccount(cap: Capability) { + access(Manage) fun addOwnedAccount(cap: Capability) { pre { self.ownedAccounts[cap.address] == nil: "There is already an owned account with this address" } @@ -424,7 +424,7 @@ access(all) contract HybridCustody { /// Removes specified child account from the Manager's child accounts. Callbacks to the child account remove /// any associated resources and Capabilities /// - access(Manage | Remove) fun removeOwned(addr: Address) { + access(Manage) fun removeOwned(addr: Address) { if let acct = self.ownedAccounts.remove(key: addr) { if acct.check() { acct.borrow()!.seal() @@ -954,7 +954,7 @@ access(all) contract HybridCustody { /// configured for the provided parent address. Once done, the parent will not have any valid capabilities with /// which to access the child account. /// - access(Owner | Remove) fun removeParent(parent: Address): Bool { + access(Owner) fun removeParent(parent: Address): Bool { if self.parents[parent] == nil { return false } @@ -983,8 +983,8 @@ access(all) contract HybridCustody { emit AccountUpdated(id: self.uuid, child: self.acct.address, parent: parent, active: false) let parentManager = getAccount(parent).capabilities.get<&{ManagerPublic}>(HybridCustody.ManagerPublicPath) - if parentManager?.check() == true { - parentManager!.borrow()?.removeParentCallback(child: acct.address) + if parentManager.check() { + parentManager.borrow()?.removeParentCallback(child: acct.address) } return true diff --git a/contracts/factories/NFTCollectionFactory.cdc b/contracts/factories/NFTCollectionFactory.cdc index 5b006bf..caf4dec 100644 --- a/contracts/factories/NFTCollectionFactory.cdc +++ b/contracts/factories/NFTCollectionFactory.cdc @@ -5,11 +5,11 @@ access(all) contract NFTProviderAndCollectionFactory { access(all) struct WithdrawFactory: CapabilityFactory.Factory { access(all) view fun getCapability(acct: auth(Capabilities) &Account, controllerID: UInt64): Capability? { if let con = acct.capabilities.storage.getController(byCapabilityID: controllerID) { - if !con.capability.check() { + if !con.capability.check() { return nil } - return con.capability as! Capability + return con.capability as! Capability } return nil @@ -34,15 +34,12 @@ access(all) contract NFTProviderAndCollectionFactory { } access(all) view fun getPublicCapability(acct: &Account, path: PublicPath): Capability? { - if let cap = acct.capabilities.get<&{NonFungibleToken.Collection}>(path) { - if !cap.check() { - return nil - } - - return cap + let cap = acct.capabilities.get<&{NonFungibleToken.Collection}>(path) + if !cap.check() { + return nil } - - return nil + + return cap } } } \ No newline at end of file diff --git a/contracts/factories/NFTProviderAndCollectionFactory.cdc b/contracts/factories/NFTProviderAndCollectionFactory.cdc index cf02cf2..ebeb4e4 100644 --- a/contracts/factories/NFTProviderAndCollectionFactory.cdc +++ b/contracts/factories/NFTProviderAndCollectionFactory.cdc @@ -5,11 +5,11 @@ access(all) contract NFTProviderAndCollectionFactory { access(all) struct Factory: CapabilityFactory.Factory { access(all) view fun getCapability(acct: auth(Capabilities) &Account, controllerID: UInt64): Capability? { if let con = acct.capabilities.storage.getController(byCapabilityID: controllerID) { - if !con.capability.check() { + if !con.capability.check() { return nil } - return con.capability as! Capability + return con.capability as! Capability } return nil diff --git a/contracts/factories/NFTProviderFactory.cdc b/contracts/factories/NFTProviderFactory.cdc index fcb8486..a2214dc 100644 --- a/contracts/factories/NFTProviderFactory.cdc +++ b/contracts/factories/NFTProviderFactory.cdc @@ -5,11 +5,11 @@ access(all) contract NFTProviderFactory { access(all) struct Factory: CapabilityFactory.Factory { access(all) view fun getCapability(acct: auth(Capabilities) &Account, controllerID: UInt64): Capability? { if let con = acct.capabilities.storage.getController(byCapabilityID: controllerID) { - if !con.capability.check() { + if !con.capability.check() { return nil } - return con.capability as! Capability + return con.capability as! Capability } return nil diff --git a/contracts/standard/ExampleNFT.cdc b/contracts/standard/ExampleNFT.cdc index 60e1d77..b80e993 100644 --- a/contracts/standard/ExampleNFT.cdc +++ b/contracts/standard/ExampleNFT.cdc @@ -155,7 +155,7 @@ access(all) contract ExampleNFT: ViewResolver { } // withdraw removes an NFT from the collection and moves it to the caller - access(NonFungibleToken.Withdraw | NonFungibleToken.Owner) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} { + access(NonFungibleToken.Withdraw) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} { let token <- self.ownedNFTs.remove(key: withdrawID) ?? panic("missing NFT") emit Withdraw(id: token.id, from: self.owner?.address) diff --git a/contracts/standard/ExampleNFT2.cdc b/contracts/standard/ExampleNFT2.cdc index 21f417c..cc65ad7 100644 --- a/contracts/standard/ExampleNFT2.cdc +++ b/contracts/standard/ExampleNFT2.cdc @@ -155,7 +155,7 @@ access(all) contract ExampleNFT2: ViewResolver { } // withdraw removes an NFT from the collection and moves it to the caller - access(NonFungibleToken.Withdraw | NonFungibleToken.Owner) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} { + access(NonFungibleToken.Withdraw ) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} { let token <- self.ownedNFTs.remove(key: withdrawID) ?? panic("missing NFT") emit Withdraw(id: token.id, from: self.owner?.address) diff --git a/package-lock.json b/package-lock.json index adba3c5..d8f1faa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,13 +9,13 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@flowtyio/flow-contracts": "^0.1.0-beta.11" + "@flowtyio/flow-contracts": "^0.1.0-beta.19" } }, "node_modules/@flowtyio/flow-contracts": { - "version": "0.1.0-beta.11", - "resolved": "https://registry.npmjs.org/@flowtyio/flow-contracts/-/flow-contracts-0.1.0-beta.11.tgz", - "integrity": "sha512-4D1JHCrV6KxRgKEsfGxzVxAYrEjq51N0tlVy7gi+Ne7YhWQ+Jp7ha+QwPxuLIYkjMZjMzoM/dD6WedZQERgFSg==", + "version": "0.1.0-beta.19", + "resolved": "https://registry.npmjs.org/@flowtyio/flow-contracts/-/flow-contracts-0.1.0-beta.19.tgz", + "integrity": "sha512-s88ttcc+BYwgR+eXyIAtL8bXPaSj2lVQgbpD+7huadfst8N8gri3g4uaS8KxXkHZw4WQojJmaoc16Fkvlp93gQ==", "dependencies": { "commander": "^11.0.0" }, diff --git a/package.json b/package.json index 31de31f..350d7f7 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,6 @@ "author": "", "license": "ISC", "dependencies": { - "@flowtyio/flow-contracts": "^0.1.0-beta.11" + "@flowtyio/flow-contracts": "^0.1.0-beta.19" } } diff --git a/scripts/delegator/find_nft_provider_cap.cdc b/scripts/delegator/find_nft_provider_cap.cdc index 5a60b9e..2916183 100644 --- a/scripts/delegator/find_nft_provider_cap.cdc +++ b/scripts/delegator/find_nft_provider_cap.cdc @@ -10,7 +10,7 @@ access(all) fun main(addr: Address): Bool { acct.capabilities.storage.issue(CapabilityDelegator.StoragePath).borrow() ?? panic("could not borrow delegator") - let desiredType = Type>() + let desiredType = Type>() let foundType = delegator.findFirstPrivateType(desiredType) ?? panic("no type found") let nakedCap = delegator.getPrivateCapability(foundType) ?? panic("requested capability type was not found") diff --git a/scripts/delegator/get_all_private_caps.cdc b/scripts/delegator/get_all_private_caps.cdc index 12ab8ee..8c0b48c 100644 --- a/scripts/delegator/get_all_private_caps.cdc +++ b/scripts/delegator/get_all_private_caps.cdc @@ -9,7 +9,7 @@ access(all) fun main(address: Address): Bool { ?.getAllPrivate() ?? panic("could not borrow delegator") - let desiredType: Type = Type>() + let desiredType: Type = Type>() return privateCaps.length == 1 && privateCaps[0].getType() == desiredType } \ No newline at end of file diff --git a/scripts/delegator/get_nft_provider.cdc b/scripts/delegator/get_nft_provider.cdc index ab4bbd0..0753b65 100644 --- a/scripts/delegator/get_nft_provider.cdc +++ b/scripts/delegator/get_nft_provider.cdc @@ -10,12 +10,12 @@ access(all) fun main(addr: Address): Bool { acct.capabilities.storage.issue(CapabilityDelegator.StoragePath).borrow() ?? panic("could not borrow delegator") - let capType = Type>() + let capType = Type>() let nakedCap = delegator.getPrivateCapability(capType) ?? panic("requested capability type was not found") // we don't need to do anything with this cap, being able to cast here is enough to know // that this works - let cap = nakedCap as! Capability + let cap = nakedCap as! Capability return true } \ No newline at end of file diff --git a/scripts/factory/get_nft_provider_from_factory.cdc b/scripts/factory/get_nft_provider_from_factory.cdc index 794037a..c49019c 100644 --- a/scripts/factory/get_nft_provider_from_factory.cdc +++ b/scripts/factory/get_nft_provider_from_factory.cdc @@ -13,8 +13,8 @@ access(all) fun main(addr: Address) { let controllers = acct.capabilities.storage.getControllers(forPath: d.storagePath) for c in controllers { - if c.borrowType.isSubtype(of: Type()) { - factory.getCapability(acct: acct, controllerID: c.capabilityID)! as! Capability + if c.borrowType.isSubtype(of: Type()) { + factory.getCapability(acct: acct, controllerID: c.capabilityID)! as! Capability return } } diff --git a/scripts/factory/get_nft_provider_from_factory_allowed.cdc b/scripts/factory/get_nft_provider_from_factory_allowed.cdc index 7b8e646..4c963da 100644 --- a/scripts/factory/get_nft_provider_from_factory_allowed.cdc +++ b/scripts/factory/get_nft_provider_from_factory_allowed.cdc @@ -15,14 +15,14 @@ access(all) fun main(filterFactoryAddr: Address, providerAddr: Address): Bool { let factoryManager = ruleAcct.storage.borrow<&CapabilityFactory.Manager>(from: CapabilityFactory.StoragePath) ?? panic("Problem borrowing CapabilityFactory Manager") - let factory = factoryManager.getFactory(Type()) + let factory = factoryManager.getFactory(Type()) ?? panic("No factory for NFT Provider found") let d = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData var controllerID: UInt64? = nil for c in providerAcct.capabilities.storage.getControllers(forPath: d.storagePath) { - if c.borrowType.isSubtype(of: Type()) { + if c.borrowType.isSubtype(of: Type()) { controllerID = c.capabilityID break } @@ -30,7 +30,7 @@ access(all) fun main(filterFactoryAddr: Address, providerAddr: Address): Bool { assert(controllerID != nil, message: "could not find existing provider capcon") - let provider = factory.getCapability(acct: providerAcct, controllerID: controllerID!)! as! Capability + let provider = factory.getCapability(acct: providerAcct, controllerID: controllerID!)! as! Capability let filter = ruleAcct.storage.borrow<&CapabilityFilter.AllowlistFilter>(from: CapabilityFilter.StoragePath) ?? panic("Problem borrowing CapabilityFilter AllowlistFilter") diff --git a/scripts/hybrid-custody/get_account_public_address.cdc b/scripts/hybrid-custody/get_account_public_address.cdc index aed9558..330e1d0 100644 --- a/scripts/hybrid-custody/get_account_public_address.cdc +++ b/scripts/hybrid-custody/get_account_public_address.cdc @@ -2,7 +2,6 @@ import "HybridCustody" access(all) fun main(parent: Address, child: Address): Address { let cap = getAccount(parent).capabilities.get<&{HybridCustody.ManagerPublic}>(HybridCustody.ManagerPublicPath) - ?? panic("manager not found") let manager = cap.borrow() ?? panic("unable to borrow manager") diff --git a/scripts/hybrid-custody/get_child_account_nft_capabilities.cdc b/scripts/hybrid-custody/get_child_account_nft_capabilities.cdc index 0f76545..85978f4 100644 --- a/scripts/hybrid-custody/get_child_account_nft_capabilities.cdc +++ b/scripts/hybrid-custody/get_child_account_nft_capabilities.cdc @@ -9,7 +9,7 @@ access(all) fun main(addr: Address): AnyStruct { var typeIdsWithProvider: {Address: [String]} = {} - let providerType = Type() + let providerType = Type() // Iterate through child accounts for address in manager.getChildAddresses() { @@ -26,7 +26,7 @@ access(all) fun main(addr: Address): AnyStruct { } if let cap = childAcct.getCapability(controllerID: c.capabilityID, type: providerType) { - let providerCap = cap as! Capability + let providerCap = cap as! Capability if !providerCap.check(){ continue diff --git a/scripts/hybrid-custody/get_nft_provider_capability.cdc b/scripts/hybrid-custody/get_nft_provider_capability.cdc index 6ab97b6..d80c390 100644 --- a/scripts/hybrid-custody/get_nft_provider_capability.cdc +++ b/scripts/hybrid-custody/get_nft_provider_capability.cdc @@ -14,7 +14,7 @@ access(all) fun main(parent: Address, child: Address) { let d = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData - let desiredType = Type() + let desiredType = Type() let controllerID = childAcct.getControllerIDForType(type: desiredType, forPath: d.storagePath) ?? panic("no capability found for desired type") diff --git a/scripts/test/get_nft_provider_capability_optional.cdc b/scripts/test/get_nft_provider_capability_optional.cdc index 065258c..635cb9d 100644 --- a/scripts/test/get_nft_provider_capability_optional.cdc +++ b/scripts/test/get_nft_provider_capability_optional.cdc @@ -14,7 +14,7 @@ access(all) fun main(parent: Address, child: Address, returnsNil: Bool): Bool { let collectionData = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData - let type = Type() + let type = Type() let controllerID = childAcct.getControllerIDForType(type: type, forPath: collectionData.storagePath) ?? panic("could not find controller for desired type") diff --git a/scripts/test/remove_nft_provider_factory.cdc b/scripts/test/remove_nft_provider_factory.cdc index 92537d1..566b778 100644 --- a/scripts/test/remove_nft_provider_factory.cdc +++ b/scripts/test/remove_nft_provider_factory.cdc @@ -10,7 +10,7 @@ access(all) fun main(address: Address): Bool { let expectedType = Type() - if let removed = managerRef.removeFactory(Type()) { + if let removed = managerRef.removeFactory(Type()) { return removed.getType() == expectedType } diff --git a/scripts/test/test_get_accessible_child_nfts.cdc b/scripts/test/test_get_accessible_child_nfts.cdc index 54f3043..587dc6b 100644 --- a/scripts/test/test_get_accessible_child_nfts.cdc +++ b/scripts/test/test_get_accessible_child_nfts.cdc @@ -29,7 +29,7 @@ access(all) fun main(addr: Address, expectedAddressToIDs: {Address: [UInt64]}){ var typeIdsWithProvider: {Address: [String]} = {} var nftViews: {Address: {UInt64: MetadataViews.Display}} = {} - let providerType = Type() + let providerType = Type() let collectionType: Type = Type<@{NonFungibleToken.CollectionPublic}>() for address in manager.getChildAddresses() { diff --git a/test/CapabilityDelegator_tests.cdc b/test/CapabilityDelegator_tests.cdc index 1c481d3..0fd099e 100644 --- a/test/CapabilityDelegator_tests.cdc +++ b/test/CapabilityDelegator_tests.cdc @@ -60,7 +60,7 @@ fun testShareExampleNFTCollectionPrivate() { Test.assert(e.isPublic == false) Test.assert(e.active) - let capabilityType = Type>() + let capabilityType = Type>() Test.assertEqual(capabilityType, e.capabilityType) } @@ -101,7 +101,7 @@ fun testRemoveExampleNFTCollectionPrivate() { Test.assert(e.isPublic == false) Test.assert(e.active == false) - let capabilityType = Type>() + let capabilityType = Type>() Test.assertEqual(capabilityType, e.capabilityType) let scriptCode = loadCode("delegator/find_nft_provider_cap.cdc", "scripts") diff --git a/test/CapabilityFactory_tests.cdc b/test/CapabilityFactory_tests.cdc index 4227078..2180c30 100644 --- a/test/CapabilityFactory_tests.cdc +++ b/test/CapabilityFactory_tests.cdc @@ -38,9 +38,9 @@ fun testGetSupportedTypesFromManager() { Type<&{FungibleToken.Receiver}>(), Type<&{FungibleToken.Receiver, FungibleToken.Balance}>(), Type(), - Type(), + Type(), Type<&{NonFungibleToken.CollectionPublic}>(), - Type() + Type() ] for e in expectedTypes { Test.assert(supportedTypes.contains(e), message: "missing expected type in supported types") @@ -51,7 +51,7 @@ access(all) fun testAddFactoryFails() { expectScriptFailure( "test/add_type_for_nft_provider_factory.cdc", - [creator.address, Type()], + [creator.address, Type()], "Factory of given type already exists" ) } @@ -71,9 +71,9 @@ fun testAddFactorySucceeds() { Type<&{FungibleToken.Receiver}>(), Type<&{FungibleToken.Receiver, FungibleToken.Balance}>(), Type(), - Type(), + Type(), Type<&{NonFungibleToken.CollectionPublic}>(), - Type(), + Type(), Type<&{NonFungibleToken.Receiver}>() ] @@ -121,9 +121,9 @@ fun testSetupNFTManager() { let supportedTypes = scriptExecutor("factory/get_supported_types_from_manager.cdc", [tmp.address])! as! [Type] let expectedTypes = [ - Type(), + Type(), Type<&{NonFungibleToken.CollectionPublic}>(), - Type() + Type() ] for e in expectedTypes { @@ -180,9 +180,9 @@ fun testSetupNFTFTManager() { Type<&{FungibleToken.Receiver}>(), Type<&{FungibleToken.Receiver, FungibleToken.Balance}>(), Type(), - Type(), + Type(), Type<&{NonFungibleToken.CollectionPublic}>(), - Type() + Type() ] for e in expectedTypes { diff --git a/transactions/delegator/add_private_nft_collection.cdc b/transactions/delegator/add_private_nft_collection.cdc index e023565..e24a49c 100644 --- a/transactions/delegator/add_private_nft_collection.cdc +++ b/transactions/delegator/add_private_nft_collection.cdc @@ -11,7 +11,7 @@ transaction { let d = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData - let sharedCap = acct.capabilities.storage.issue(d.storagePath) + let sharedCap = acct.capabilities.storage.issue(d.storagePath) delegator.addCapability(cap: sharedCap, isPublic: false) } diff --git a/transactions/delegator/remove_private_nft_collection.cdc b/transactions/delegator/remove_private_nft_collection.cdc index 6eb0924..82d2ada 100644 --- a/transactions/delegator/remove_private_nft_collection.cdc +++ b/transactions/delegator/remove_private_nft_collection.cdc @@ -11,7 +11,7 @@ transaction { let d = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData - let sharedCap = acct.capabilities.storage.issue(d.storagePath) + let sharedCap = acct.capabilities.storage.issue(d.storagePath) delegator.removeCapability(cap: sharedCap) diff --git a/transactions/dev-setup/setup_nft_filter_and_factory_manager.cdc b/transactions/dev-setup/setup_nft_filter_and_factory_manager.cdc index 23035d6..2ec061e 100644 --- a/transactions/dev-setup/setup_nft_filter_and_factory_manager.cdc +++ b/transactions/dev-setup/setup_nft_filter_and_factory_manager.cdc @@ -54,7 +54,7 @@ transaction(nftContractAddress: Address, nftContractName: String) { acct.storage.save(<-f, to: CapabilityFactory.StoragePath) } - if acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)?.check() != true { + if !acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check() { acct.capabilities.unpublish(CapabilityFactory.PublicPath) acct.capabilities.publish( acct.capabilities.storage.issue<&{CapabilityFactory.Getter}>(CapabilityFactory.StoragePath), @@ -63,7 +63,7 @@ transaction(nftContractAddress: Address, nftContractName: String) { } assert( - acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)?.check() == true, + acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check() == true, message: "CapabilityFactory is not setup properly" ) @@ -72,8 +72,8 @@ transaction(nftContractAddress: Address, nftContractName: String) { // Add NFT-related Factories to the Manager factoryManager.updateFactory(Type<&{NonFungibleToken.CollectionPublic}>(), NFTCollectionPublicFactory.Factory()) - factoryManager.updateFactory(Type(), NFTProviderAndCollectionFactory.Factory()) - factoryManager.updateFactory(Type(), NFTProviderFactory.Factory()) + factoryManager.updateFactory(Type(), NFTProviderAndCollectionFactory.Factory()) + factoryManager.updateFactory(Type(), NFTProviderFactory.Factory()) /* --- AllowlistFilter configuration --- */ // @@ -81,7 +81,7 @@ transaction(nftContractAddress: Address, nftContractName: String) { acct.storage.save(<-CapabilityFilter.createFilter(Type<@CapabilityFilter.AllowlistFilter>()), to: CapabilityFilter.StoragePath) } - if acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath)?.check() != true { + if !acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath).check(){ acct.capabilities.unpublish(CapabilityFilter.PublicPath) acct.capabilities.publish( @@ -91,7 +91,7 @@ transaction(nftContractAddress: Address, nftContractName: String) { } assert( - acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath)?.check() == true, + acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath).check(), message: "AllowlistFilter is not setup properly" ) diff --git a/transactions/example-nft-2/mint_to_account.cdc b/transactions/example-nft-2/mint_to_account.cdc index 0be32eb..5d5e61a 100644 --- a/transactions/example-nft-2/mint_to_account.cdc +++ b/transactions/example-nft-2/mint_to_account.cdc @@ -13,7 +13,7 @@ transaction(receiver: Address, name: String, description: String, thumbnail: Str execute { let d = ExampleNFT2.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData - let c = getAccount(receiver).capabilities.get<&{NonFungibleToken.CollectionPublic}>(d.publicPath) ?? panic("receiver capability was nil") + let c = getAccount(receiver).capabilities.get<&{NonFungibleToken.CollectionPublic}>(d.publicPath) let r = c.borrow() ?? panic("no receiver collection") self.minter.mintNFT(recipient: r, name: name, description: description, thumbnail: thumbnail, royaltyReceipient: self.minter.owner!.address) } diff --git a/transactions/example-nft-2/setup_full.cdc b/transactions/example-nft-2/setup_full.cdc index 16049f1..b72b7a1 100644 --- a/transactions/example-nft-2/setup_full.cdc +++ b/transactions/example-nft-2/setup_full.cdc @@ -17,6 +17,6 @@ transaction { at: d.publicPath ) - acct.capabilities.storage.issue(d.storagePath) + acct.capabilities.storage.issue(d.storagePath) } } diff --git a/transactions/example-nft/mint_to_account.cdc b/transactions/example-nft/mint_to_account.cdc index 699d022..ac7bd44 100644 --- a/transactions/example-nft/mint_to_account.cdc +++ b/transactions/example-nft/mint_to_account.cdc @@ -13,7 +13,7 @@ transaction(receiver: Address, name: String, description: String, thumbnail: Str execute { let d = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type())! as! MetadataViews.NFTCollectionData - let c = getAccount(receiver).capabilities.get<&{NonFungibleToken.CollectionPublic}>(d.publicPath) ?? panic("receiver capability was nil") + let c = getAccount(receiver).capabilities.get<&{NonFungibleToken.CollectionPublic}>(d.publicPath) let r = c.borrow() ?? panic("no receiver collection") self.minter.mintNFT(recipient: r, name: name, description: description, thumbnail: thumbnail, royaltyReceipient: self.minter.owner!.address) } diff --git a/transactions/example-nft/setup_full.cdc b/transactions/example-nft/setup_full.cdc index 550e50a..c20ad67 100644 --- a/transactions/example-nft/setup_full.cdc +++ b/transactions/example-nft/setup_full.cdc @@ -15,6 +15,6 @@ transaction { let cap = acct.capabilities.storage.issue<&{ExampleNFT.ExampleNFTCollectionPublic, NonFungibleToken.CollectionPublic}>(d.storagePath) acct.capabilities.publish(cap, at: d.publicPath) - acct.capabilities.storage.issue(d.storagePath) + acct.capabilities.storage.issue(d.storagePath) } } diff --git a/transactions/factory/setup_empty_factory.cdc b/transactions/factory/setup_empty_factory.cdc index 4a49b8c..c6cabe5 100644 --- a/transactions/factory/setup_empty_factory.cdc +++ b/transactions/factory/setup_empty_factory.cdc @@ -10,7 +10,7 @@ transaction { acct.storage.save(<-f, to: CapabilityFactory.StoragePath) } - if acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)?.check() != true { + if !acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check() { acct.capabilities.unpublish(CapabilityFactory.PublicPath) let cap = acct.capabilities.storage.issue<&{CapabilityFactory.Getter}>(CapabilityFactory.StoragePath) @@ -18,7 +18,7 @@ transaction { } assert( - acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)!.check(), + acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check(), message: "CapabilityFactory is not setup properly" ) } diff --git a/transactions/factory/setup_ft_manager.cdc b/transactions/factory/setup_ft_manager.cdc index 287affe..ac963df 100644 --- a/transactions/factory/setup_ft_manager.cdc +++ b/transactions/factory/setup_ft_manager.cdc @@ -14,7 +14,7 @@ transaction { acct.storage.save(<-f, to: CapabilityFactory.StoragePath) } - if acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)?.check() != true { + if !acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check() { acct.capabilities.unpublish(CapabilityFactory.PublicPath) acct.capabilities.publish( acct.capabilities.storage.issue<&{CapabilityFactory.Getter}>(CapabilityFactory.StoragePath), @@ -23,7 +23,7 @@ transaction { } assert( - acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)!.check(), + acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check(), message: "CapabilityFactory is not setup properly" ) diff --git a/transactions/factory/setup_nft_ft_manager.cdc b/transactions/factory/setup_nft_ft_manager.cdc index 976eb87..30c373e 100644 --- a/transactions/factory/setup_nft_ft_manager.cdc +++ b/transactions/factory/setup_nft_ft_manager.cdc @@ -18,7 +18,7 @@ transaction { acct.storage.save(<-f, to: CapabilityFactory.StoragePath) } - if acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)?.check() != true { + if !acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check() { acct.capabilities.unpublish(CapabilityFactory.PublicPath) let cap = acct.capabilities.storage.issue<&{CapabilityFactory.Getter}>(CapabilityFactory.StoragePath) @@ -26,15 +26,15 @@ transaction { } assert( - acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)!.check(), + acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check(), message: "CapabilityFactory is not setup properly" ) let manager = acct.storage.borrow(from: CapabilityFactory.StoragePath) ?? panic("manager not found") manager.updateFactory(Type<&{NonFungibleToken.CollectionPublic}>(), NFTCollectionPublicFactory.Factory()) - manager.updateFactory(Type(), NFTProviderAndCollectionFactory.Factory()) - manager.updateFactory(Type(), NFTProviderFactory.Factory()) + manager.updateFactory(Type(), NFTProviderAndCollectionFactory.Factory()) + manager.updateFactory(Type(), NFTProviderFactory.Factory()) manager.updateFactory(Type(), FTProviderFactory.Factory()) manager.updateFactory(Type<&{FungibleToken.Balance}>(), FTBalanceFactory.Factory()) manager.updateFactory(Type<&{FungibleToken.Receiver}>(), FTReceiverFactory.Factory()) diff --git a/transactions/factory/setup_nft_manager.cdc b/transactions/factory/setup_nft_manager.cdc index fb1ba73..a87841d 100644 --- a/transactions/factory/setup_nft_manager.cdc +++ b/transactions/factory/setup_nft_manager.cdc @@ -20,7 +20,7 @@ transaction { ) assert( - acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)!.check(), + acct.capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath).check(), message: "CapabilityFactory is not setup properly" ) @@ -28,7 +28,7 @@ transaction { ?? panic("manager not found") manager.updateFactory(Type<&{NonFungibleToken.CollectionPublic}>(), NFTCollectionPublicFactory.Factory()) - manager.updateFactory(Type(), NFTProviderAndCollectionFactory.Factory()) - manager.updateFactory(Type(), NFTProviderFactory.Factory()) + manager.updateFactory(Type(), NFTProviderAndCollectionFactory.Factory()) + manager.updateFactory(Type(), NFTProviderFactory.Factory()) } } diff --git a/transactions/filter/allow/setup.cdc b/transactions/filter/allow/setup.cdc index f6e2e57..d3765f6 100644 --- a/transactions/filter/allow/setup.cdc +++ b/transactions/filter/allow/setup.cdc @@ -12,6 +12,6 @@ transaction { at: CapabilityFilter.PublicPath ) - assert(acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath)?.check() == true, message: "failed to setup filter") + assert(acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath).check(), message: "failed to setup filter") } } \ No newline at end of file diff --git a/transactions/filter/deny/setup.cdc b/transactions/filter/deny/setup.cdc index c4760e8..d5a78b4 100644 --- a/transactions/filter/deny/setup.cdc +++ b/transactions/filter/deny/setup.cdc @@ -12,6 +12,6 @@ transaction { at: CapabilityFilter.PublicPath ) - assert(acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath)?.check() == true, message: "failed to setup filter") + assert(acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath).check(), message: "failed to setup filter") } } \ No newline at end of file diff --git a/transactions/filter/setup_allow_all.cdc b/transactions/filter/setup_allow_all.cdc index 0a8b0b5..dfe1e00 100644 --- a/transactions/filter/setup_allow_all.cdc +++ b/transactions/filter/setup_allow_all.cdc @@ -12,6 +12,6 @@ transaction { at: CapabilityFilter.PublicPath ) - assert(acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath)?.check() == true, message: "failed to setup filter") + assert(acct.capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath).check(), message: "failed to setup filter") } } \ No newline at end of file diff --git a/transactions/hybrid-custody/accept_ownership.cdc b/transactions/hybrid-custody/accept_ownership.cdc index 8225d57..0ef08c0 100644 --- a/transactions/hybrid-custody/accept_ownership.cdc +++ b/transactions/hybrid-custody/accept_ownership.cdc @@ -9,7 +9,6 @@ transaction(childAddress: Address, filterAddress: Address?, filterPath: PublicPa var filter: Capability<&{CapabilityFilter.Filter}>? = nil if filterAddress != nil && filterPath != nil { filter = getAccount(filterAddress!).capabilities.get<&{CapabilityFilter.Filter}>(filterPath!) - ?? panic("filter address given but capability was not found") } if acct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { diff --git a/transactions/hybrid-custody/add_example_nft2_collection_to_delegator.cdc b/transactions/hybrid-custody/add_example_nft2_collection_to_delegator.cdc index ce420e3..558091c 100644 --- a/transactions/hybrid-custody/add_example_nft2_collection_to_delegator.cdc +++ b/transactions/hybrid-custody/add_example_nft2_collection_to_delegator.cdc @@ -11,7 +11,7 @@ transaction(parent: Address, isPublic: Bool) { let child = o.borrowChildAccount(parent: parent) ?? panic("child account not found") - let cap = acct.capabilities.storage.issue(ExampleNFT2.CollectionStoragePath) + let cap = acct.capabilities.storage.issue(ExampleNFT2.CollectionStoragePath) o.addCapabilityToDelegator(parent: parent, cap: cap, isPublic: isPublic) } } \ No newline at end of file diff --git a/transactions/hybrid-custody/onboarding/blockchain_native.cdc b/transactions/hybrid-custody/onboarding/blockchain_native.cdc index 7f6613c..2141803 100644 --- a/transactions/hybrid-custody/onboarding/blockchain_native.cdc +++ b/transactions/hybrid-custody/onboarding/blockchain_native.cdc @@ -82,7 +82,6 @@ transaction( // Get the CapabilityFilter.Filter Capability let filter = getAccount(filterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("filter capability was not valid") assert(filter.check(), message: "capability filter is not configured properly") // Configure access for the delegatee parent account diff --git a/transactions/hybrid-custody/publish_to_parent.cdc b/transactions/hybrid-custody/publish_to_parent.cdc index 6f0612d..cfcff26 100644 --- a/transactions/hybrid-custody/publish_to_parent.cdc +++ b/transactions/hybrid-custody/publish_to_parent.cdc @@ -8,10 +8,10 @@ transaction(parent: Address, factoryAddress: Address, filterAddress: Address) { let owned = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned account not found") - let factory = getAccount(factoryAddress).capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath)! + let factory = getAccount(factoryAddress).capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath) assert(factory.check(), message: "factory address is not configured properly") - let filter = getAccount(filterAddress).capabilities.get<&{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/transactions/hybrid-custody/redeem_account.cdc b/transactions/hybrid-custody/redeem_account.cdc index b28a49a..82a757e 100644 --- a/transactions/hybrid-custody/redeem_account.cdc +++ b/transactions/hybrid-custody/redeem_account.cdc @@ -9,7 +9,6 @@ transaction(childAddress: Address, filterAddress: Address?, filterPath: PublicPa var filter: Capability<&{CapabilityFilter.Filter}>? = nil if filterAddress != nil && filterPath != nil { filter = getAccount(filterAddress!).capabilities.get<&{CapabilityFilter.Filter}>(filterPath!) - ?? panic("filter path provided but capability was not found") } if acct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { diff --git a/transactions/hybrid-custody/remove_parent_from_child.cdc b/transactions/hybrid-custody/remove_parent_from_child.cdc index f073054..5b57b7c 100644 --- a/transactions/hybrid-custody/remove_parent_from_child.cdc +++ b/transactions/hybrid-custody/remove_parent_from_child.cdc @@ -7,7 +7,7 @@ transaction(parent: Address) { owned.removeParent(parent: parent) - let manager = getAccount(parent).capabilities.get<&{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/transactions/hybrid-custody/set_capability_factory_for_parent.cdc b/transactions/hybrid-custody/set_capability_factory_for_parent.cdc index cf1bc8a..86d8b5e 100644 --- a/transactions/hybrid-custody/set_capability_factory_for_parent.cdc +++ b/transactions/hybrid-custody/set_capability_factory_for_parent.cdc @@ -4,7 +4,6 @@ import "CapabilityFactory" transaction(parent: Address, factoryAddress: Address) { prepare(acct: auth(Storage) &Account) { let cap = getAccount(factoryAddress).capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath) - ?? panic("capability factory was nil") let ownedAccount = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned account not found") diff --git a/transactions/hybrid-custody/set_capability_filter_for_parent.cdc b/transactions/hybrid-custody/set_capability_filter_for_parent.cdc index 3fdf350..7446af6 100644 --- a/transactions/hybrid-custody/set_capability_filter_for_parent.cdc +++ b/transactions/hybrid-custody/set_capability_filter_for_parent.cdc @@ -4,7 +4,6 @@ import "CapabilityFilter" transaction(parent: Address, factoryAddress: Address) { prepare(acct: auth(Storage) &Account) { let cap = getAccount(factoryAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("capability filter was nil") let ownedAccount = acct.storage.borrow(from: HybridCustody.OwnedAccountStoragePath) ?? panic("owned account not found") diff --git a/transactions/hybrid-custody/set_default_manager_cap.cdc b/transactions/hybrid-custody/set_default_manager_cap.cdc index d54e2f5..732692d 100644 --- a/transactions/hybrid-custody/set_default_manager_cap.cdc +++ b/transactions/hybrid-custody/set_default_manager_cap.cdc @@ -9,7 +9,6 @@ transaction(addr: Address) { ?? panic("manager not found") let cap = getAccount(addr).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("invalid capability filter address found") manager.setDefaultManagerCapabilityFilter(cap: cap) } } \ No newline at end of file diff --git a/transactions/hybrid-custody/set_manager_filter_cap.cdc b/transactions/hybrid-custody/set_manager_filter_cap.cdc index 4ea9fc7..abadc0b 100644 --- a/transactions/hybrid-custody/set_manager_filter_cap.cdc +++ b/transactions/hybrid-custody/set_manager_filter_cap.cdc @@ -7,7 +7,6 @@ transaction(filterAddress: Address, childAddress: Address) { ?? panic("manager not found") let cap = getAccount(filterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("failed to get filter capability") assert(cap.check(), message: "capability filter is not valid") m.setManagerCapabilityFilter(cap: cap, childAddress: childAddress) diff --git a/transactions/hybrid-custody/setup_multi_sig.cdc b/transactions/hybrid-custody/setup_multi_sig.cdc index 35aba71..f00ae56 100644 --- a/transactions/hybrid-custody/setup_multi_sig.cdc +++ b/transactions/hybrid-custody/setup_multi_sig.cdc @@ -48,7 +48,6 @@ transaction(parentFilterAddress: Address?, childAccountFactoryAddress: Address, var filter: Capability<&{CapabilityFilter.Filter}>? = nil if parentFilterAddress != nil { filter = getAccount(parentFilterAddress!).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("parent filter address provided but it was not valid") } if parentAcct.storage.borrow<&HybridCustody.Manager>(from: HybridCustody.ManagerStoragePath) == nil { @@ -73,11 +72,9 @@ transaction(parentFilterAddress: Address?, childAccountFactoryAddress: Address, ?? panic("owned account not found") let factory = getAccount(childAccountFactoryAddress).capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath) - ?? panic("child account factory capability was nil") assert(factory.check(), message: "factory address is not configured properly") let filterForChild = getAccount(childAccountFilterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("child account filter capability was nil") assert(filterForChild.check(), message: "capability filter is not configured properly") owned.publishToParent(parentAddress: parentAcct.address, factory: factory, filter: filterForChild) diff --git a/transactions/hybrid-custody/setup_owned_account_and_publish_to_parent.cdc b/transactions/hybrid-custody/setup_owned_account_and_publish_to_parent.cdc index 6f03619..8416271 100644 --- a/transactions/hybrid-custody/setup_owned_account_and_publish_to_parent.cdc +++ b/transactions/hybrid-custody/setup_owned_account_and_publish_to_parent.cdc @@ -51,11 +51,9 @@ transaction( // Get CapabilityFactory & CapabilityFilter Capabilities let factory = getAccount(factoryAddress).capabilities.get<&{CapabilityFactory.Getter}>(CapabilityFactory.PublicPath) - ?? panic("failed to get factory capability") assert(factory.check(), message: "factory address is not configured properly") let filter = getAccount(filterAddress).capabilities.get<&{CapabilityFilter.Filter}>(CapabilityFilter.PublicPath) - ?? panic("failed to get filter capability") assert(filter.check(), message: "capability filter is not configured properly") // Finally publish a ChildAccount capability on the signing account to the specified parent