From d043d986f8dca780b6bad06828195d2038f826b2 Mon Sep 17 00:00:00 2001 From: Giovanni Sanchez <108043524+sisyphusSmiling@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:15:17 -0600 Subject: [PATCH] update bridging txn error messages --- .../bridge/nft/batch_bridge_nft_from_evm.cdc | 14 +++++++------ ...atch_bridge_nft_to_any_cadence_address.cdc | 16 +++++++++------ .../batch_bridge_nft_to_any_evm_address.cdc | 17 ++++++++++------ .../bridge/nft/batch_bridge_nft_to_evm.cdc | 17 ++++++++++------ .../bridge/nft/bridge_nft_from_evm.cdc | 17 ++++++++++------ .../nft/bridge_nft_to_any_cadence_address.cdc | 16 +++++++++------ .../nft/bridge_nft_to_any_evm_address.cdc | 15 +++++++++----- .../bridge/nft/bridge_nft_to_evm.cdc | 17 ++++++++++------ .../bridge/tokens/bridge_tokens_from_evm.cdc | 20 +++++++++++++------ .../bridge_tokens_to_any_cadence_address.cdc | 20 +++++++++++++------ .../bridge_tokens_to_any_evm_address.cdc | 14 ++++++++----- .../bridge/tokens/bridge_tokens_to_evm.cdc | 16 +++++++++------ 12 files changed, 129 insertions(+), 70 deletions(-) diff --git a/cadence/transactions/bridge/nft/batch_bridge_nft_from_evm.cdc b/cadence/transactions/bridge/nft/batch_bridge_nft_from_evm.cdc index df39eda5..d2beb2a9 100644 --- a/cadence/transactions/bridge/nft/batch_bridge_nft_from_evm.cdc +++ b/cadence/transactions/bridge/nft/batch_bridge_nft_from_evm.cdc @@ -31,7 +31,7 @@ transaction(nftIdentifier: String, ids: [UInt256]) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -49,12 +49,13 @@ transaction(nftIdentifier: String, ids: [UInt256]) { // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) ?? panic("Could not borrow ViewResolver from NFT contract with name " - .concat(nftContractName).concat(" and address ") - .concat(nftContractAddress.toString())) + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: self.nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(self.nftType.identifier)) if signer.storage.borrow<&{NonFungibleToken.Collection}>(from: collectionData.storagePath) == nil { signer.storage.save(<-collectionData.createEmptyCollection(), to: collectionData.storagePath) signer.capabilities.unpublish(collectionData.publicPath) @@ -81,7 +82,8 @@ transaction(nftIdentifier: String, ids: [UInt256]) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, @@ -102,7 +104,7 @@ transaction(nftIdentifier: String, ids: [UInt256]) { // Ensure the bridged nft is the correct type assert( nft.getType() == self.nftType, - message: "Bridged nft type mismatch - requeswted: ".concat(self.nftType.identifier) + message: "Bridged nft type mismatch - requested: ".concat(self.nftType.identifier) .concat(", received: ").concat(nft.getType().identifier) ) // Deposit the bridged NFT into the signer's collection diff --git a/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_cadence_address.cdc b/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_cadence_address.cdc index 686d26bb..9de56dd1 100644 --- a/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_cadence_address.cdc +++ b/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_cadence_address.cdc @@ -33,7 +33,7 @@ transaction(nftIdentifier: String, ids: [UInt256], recipient: Address) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -50,11 +50,14 @@ transaction(nftIdentifier: String, ids: [UInt256], recipient: Address) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: self.nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(self.nftType.identifier)) // Configure the signer's account for this NFT if signer.storage.borrow<&{NonFungibleToken.Collection}>(from: collectionData.storagePath) == nil { signer.storage.save(<-collectionData.createEmptyCollection(), to: collectionData.storagePath) @@ -63,7 +66,7 @@ transaction(nftIdentifier: String, ids: [UInt256], recipient: Address) { signer.capabilities.publish(collectionCap, at: collectionData.publicPath) } self.receiver = getAccount(recipient).capabilities.borrow<&{NonFungibleToken.Receiver}>(collectionData.publicPath) - ?? panic("Could not borrow Receiver from recipient's public capability path") + ?? panic("Could not borrow NonFungibleToken Receiver from recipient's public capability path") /* --- Configure a ScopedFTProvider --- */ // @@ -81,7 +84,8 @@ transaction(nftIdentifier: String, ids: [UInt256], recipient: Address) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, @@ -102,7 +106,7 @@ transaction(nftIdentifier: String, ids: [UInt256], recipient: Address) { // Ensure the bridged nft is the correct type assert( nft.getType() == self.nftType, - message: "Bridged nft type mismatch - requeswted: ".concat(self.nftType.identifier) + message: "Bridged nft type mismatch - requested: ".concat(self.nftType.identifier) .concat(", received: ").concat(nft.getType().identifier) ) // Deposit the bridged NFT into the signer's collection diff --git a/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_evm_address.cdc b/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_evm_address.cdc index 0a2b9995..76b24d01 100644 --- a/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_evm_address.cdc +++ b/cadence/transactions/bridge/nft/batch_bridge_nft_to_any_evm_address.cdc @@ -34,7 +34,7 @@ transaction(nftIdentifier: String, ids: [UInt64], recipient: String) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -51,14 +51,18 @@ transaction(nftIdentifier: String, ids: [UInt64], recipient: String) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: self.nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(self.nftType.identifier)) self.collection = signer.storage.borrow( from: collectionData.storagePath - ) ?? panic("Could not access signer's NFT Collection") + ) ?? panic("Could not borrow a NonFungibleToken Collection from the signer's storage path " + .concat(collectionData.storagePath.toString())) // Withdraw the requested NFT & set a cap on the withdrawable bridge fee var approxFee = FlowEVMBridgeUtils.calculateBridgeFee( @@ -66,7 +70,7 @@ transaction(nftIdentifier: String, ids: [UInt64], recipient: String) { ) + (FlowEVMBridgeConfig.baseFee * UFix64(ids.length)) // Determine if the NFT requires onboarding - this impacts the fee required self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.nftType) - ?? panic("Bridge does not support this asset type") + ?? panic("Bridge does not support the requested asset type ".concat(nftIdentifier)) // Add the onboarding fee if onboarding is necessary if self.requiresOnboarding { approxFee = approxFee + FlowEVMBridgeConfig.onboardFee @@ -84,7 +88,8 @@ transaction(nftIdentifier: String, ids: [UInt64], recipient: String) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, diff --git a/cadence/transactions/bridge/nft/batch_bridge_nft_to_evm.cdc b/cadence/transactions/bridge/nft/batch_bridge_nft_to_evm.cdc index 2997e855..e07c0c90 100644 --- a/cadence/transactions/bridge/nft/batch_bridge_nft_to_evm.cdc +++ b/cadence/transactions/bridge/nft/batch_bridge_nft_to_evm.cdc @@ -33,7 +33,7 @@ transaction(nftIdentifier: String, ids: [UInt64]) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -50,14 +50,18 @@ transaction(nftIdentifier: String, ids: [UInt64]) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: self.nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(self.nftType.identifier)) self.collection = signer.storage.borrow( from: collectionData.storagePath - ) ?? panic("Could not access signer's NFT Collection") + ) ?? panic("Could not borrow a NonFungibleToken Collection from the signer's storage path " + .concat(collectionData.storagePath.toString())) // Withdraw the requested NFT & set a cap on the withdrawable bridge fee var approxFee = FlowEVMBridgeUtils.calculateBridgeFee( @@ -65,7 +69,7 @@ transaction(nftIdentifier: String, ids: [UInt64]) { ) + (FlowEVMBridgeConfig.baseFee * UFix64(ids.length)) // Determine if the NFT requires onboarding - this impacts the fee required self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.nftType) - ?? panic("Bridge does not support this asset type") + ?? panic("Bridge does not support the requested asset type ".concat(nftIdentifier)) // Add the onboarding fee if onboarding is necessary if self.requiresOnboarding { approxFee = approxFee + FlowEVMBridgeConfig.onboardFee @@ -83,7 +87,8 @@ transaction(nftIdentifier: String, ids: [UInt64]) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, diff --git a/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc b/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc index 8c2b9907..43c73b06 100644 --- a/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc +++ b/cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc @@ -31,7 +31,7 @@ transaction(nftIdentifier: String, id: UInt256) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -48,11 +48,14 @@ transaction(nftIdentifier: String, id: UInt256) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: self.nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(self.nftType.identifier)) if signer.storage.borrow<&{NonFungibleToken.Collection}>(from: collectionData.storagePath) == nil { signer.storage.save(<-collectionData.createEmptyCollection(), to: collectionData.storagePath) signer.capabilities.unpublish(collectionData.publicPath) @@ -60,7 +63,8 @@ transaction(nftIdentifier: String, id: UInt256) { signer.capabilities.publish(collectionCap, at: collectionData.publicPath) } self.collection = signer.storage.borrow<&{NonFungibleToken.Collection}>(from: collectionData.storagePath) - ?? panic("Could not borrow collection from storage path") + ?? panic("Could not borrow a NonFungibleToken Collection from the signer's storage path " + .concat(collectionData.storagePath.toString())) /* --- Configure a ScopedFTProvider --- */ // @@ -78,7 +82,8 @@ transaction(nftIdentifier: String, id: UInt256) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, @@ -97,7 +102,7 @@ transaction(nftIdentifier: String, id: UInt256) { // Ensure the bridged nft is the correct type assert( nft.getType() == self.nftType, - message: "Bridged nft type mismatch - requeswted: ".concat(self.nftType.identifier) + message: "Bridged nft type mismatch - requested: ".concat(self.nftType.identifier) .concat(", received: ").concat(nft.getType().identifier) ) // Deposit the bridged NFT into the signer's collection diff --git a/cadence/transactions/bridge/nft/bridge_nft_to_any_cadence_address.cdc b/cadence/transactions/bridge/nft/bridge_nft_to_any_cadence_address.cdc index f90bed20..ada8f29f 100644 --- a/cadence/transactions/bridge/nft/bridge_nft_to_any_cadence_address.cdc +++ b/cadence/transactions/bridge/nft/bridge_nft_to_any_cadence_address.cdc @@ -33,7 +33,7 @@ transaction(nftIdentifier: String, id: UInt256, recipient: Address) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -50,11 +50,14 @@ transaction(nftIdentifier: String, id: UInt256, recipient: Address) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: self.nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(self.nftType.identifier)) // Configure the signer's account for this NFT if signer.storage.borrow<&{NonFungibleToken.Collection}>(from: collectionData.storagePath) == nil { signer.storage.save(<-collectionData.createEmptyCollection(), to: collectionData.storagePath) @@ -63,7 +66,7 @@ transaction(nftIdentifier: String, id: UInt256, recipient: Address) { signer.capabilities.publish(collectionCap, at: collectionData.publicPath) } self.receiver = getAccount(recipient).capabilities.borrow<&{NonFungibleToken.Receiver}>(collectionData.publicPath) - ?? panic("Could not borrow Receiver from recipient's public capability path") + ?? panic("Could not borrow NonFungibleToken Receiver from recipient's public capability path") /* --- Configure a ScopedFTProvider --- */ // @@ -81,7 +84,8 @@ transaction(nftIdentifier: String, id: UInt256, recipient: Address) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, @@ -100,7 +104,7 @@ transaction(nftIdentifier: String, id: UInt256, recipient: Address) { // Ensure the bridged nft is the correct type assert( nft.getType() == self.nftType, - message: "Bridged nft type mismatch - requeswted: ".concat(self.nftType.identifier) + message: "Bridged nft type mismatch - requested: ".concat(self.nftType.identifier) .concat(", received: ").concat(nft.getType().identifier) ) // Deposit the bridged NFT into the signer's collection diff --git a/cadence/transactions/bridge/nft/bridge_nft_to_any_evm_address.cdc b/cadence/transactions/bridge/nft/bridge_nft_to_any_evm_address.cdc index 221be214..46953e1e 100644 --- a/cadence/transactions/bridge/nft/bridge_nft_to_any_evm_address.cdc +++ b/cadence/transactions/bridge/nft/bridge_nft_to_any_evm_address.cdc @@ -42,14 +42,18 @@ transaction(nftIdentifier: String, id: UInt64, recipient: String) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: nil, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(nftType.identifier)) let collection = signer.storage.borrow( from: collectionData.storagePath - ) ?? panic("Could not access signer's NFT Collection") + ) ?? panic("Could not borrow a NonFungibleToken Collection from the signer's storage path " + .concat(collectionData.storagePath.toString())) // Withdraw the requested NFT & calculate the approximate bridge fee based on NFT storage usage self.nft <- collection.withdraw(withdrawID: id) @@ -58,7 +62,7 @@ transaction(nftIdentifier: String, id: UInt64, recipient: String) { ) // Determine if the NFT requires onboarding - this impacts the fee required self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.nft.getType()) - ?? panic("Bridge does not support this asset type") + ?? panic("Bridge does not support the requested asset type ".concat(nftIdentifier)) // Add the onboarding fee if onboarding is necessary if self.requiresOnboarding { approxFee = approxFee + FlowEVMBridgeConfig.onboardFee @@ -76,7 +80,8 @@ transaction(nftIdentifier: String, id: UInt64, recipient: String) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, diff --git a/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc b/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc index 449ef397..ed216f15 100644 --- a/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc +++ b/cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc @@ -32,7 +32,7 @@ transaction(nftIdentifier: String, id: UInt64) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the NFT type --- */ // @@ -49,14 +49,18 @@ transaction(nftIdentifier: String, id: UInt64) { // // Borrow a reference to the NFT collection, configuring if necessary let viewResolver = getAccount(nftContractAddress).contracts.borrow<&{ViewResolver}>(name: nftContractName) - ?? panic("Could not borrow ViewResolver from NFT contract") + ?? panic("Could not borrow ViewResolver from NFT contract with name " + .concat(nftContractName).concat(" and address ") + .concat(nftContractAddress.toString())) let collectionData = viewResolver.resolveContractView( resourceType: nftType, viewType: Type() - ) as! MetadataViews.NFTCollectionData? ?? panic("Could not resolve NFTCollectionData view") + ) as! MetadataViews.NFTCollectionData? + ?? panic("Could not resolve NFTCollectionData view for NFT type ".concat(nftType.identifier)) let collection = signer.storage.borrow( from: collectionData.storagePath - ) ?? panic("Could not access signer's NFT Collection") + ) ?? panic("Could not borrow a NonFungibleToken Collection from the signer's storage path " + .concat(collectionData.storagePath.toString())) // Withdraw the requested NFT & set a cap on the withdrawable bridge fee self.nft <- collection.withdraw(withdrawID: id) @@ -65,7 +69,7 @@ transaction(nftIdentifier: String, id: UInt64) { ) // Determine if the NFT requires onboarding - this impacts the fee required self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.nft.getType()) - ?? panic("Bridge does not support this asset type") + ?? panic("Bridge does not support the requested asset type ".concat(nftIdentifier)) // Add the onboarding fee if onboarding is necessary if self.requiresOnboarding { approxFee = approxFee + FlowEVMBridgeConfig.onboardFee @@ -83,7 +87,8 @@ transaction(nftIdentifier: String, id: UInt64) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, diff --git a/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc b/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc index c2bb1f92..1f61be93 100644 --- a/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc +++ b/cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc @@ -34,7 +34,7 @@ transaction(vaultIdentifier: String, amount: UInt256) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the Vault type --- */ // @@ -51,11 +51,14 @@ transaction(vaultIdentifier: String, amount: UInt256) { // // Borrow a reference to the FungibleToken Vault, configuring if necessary let viewResolver = getAccount(tokenContractAddress).contracts.borrow<&{ViewResolver}>(name: tokenContractName) - ?? panic("Could not borrow ViewResolver from FungibleToken contract") + ?? panic("Could not borrow ViewResolver from FungibleToken contract with name" + .concat(tokenContractName).concat(" and address ") + .concat(tokenContractAddress.toString())) let vaultData = viewResolver.resolveContractView( resourceType: self.vaultType, viewType: Type() - ) as! FungibleTokenMetadataViews.FTVaultData? ?? panic("Could not resolve FTVaultData view") + ) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not resolve FTVaultData view for Vault type ".concat(self.vaultType.identifier)) // If the vault does not exist, create it and publish according to the contract's defined configuration if signer.storage.borrow<&{FungibleToken.Vault}>(from: vaultData.storagePath) == nil { signer.storage.save(<-vaultData.createEmptyVault(), to: vaultData.storagePath) @@ -70,7 +73,7 @@ transaction(vaultIdentifier: String, amount: UInt256) { signer.capabilities.publish(metadataCap, at: vaultData.metadataPath) } self.receiver = signer.storage.borrow<&{FungibleToken.Vault}>(from: vaultData.storagePath) - ?? panic("Could not borrow Vault from storage path") + ?? panic("Could not borrow FungibleToken Vault from storage path ".concat(vaultData.storagePath.toString())) /* --- Configure a ScopedFTProvider --- */ // @@ -88,7 +91,8 @@ transaction(vaultIdentifier: String, amount: UInt256) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, @@ -105,7 +109,11 @@ transaction(vaultIdentifier: String, amount: UInt256) { feeProvider: &self.scopedProvider as auth(FungibleToken.Withdraw) &{FungibleToken.Provider} ) // Ensure the bridged vault is the correct type - assert(vault.getType() == self.vaultType, message: "Bridged vault type mismatch") + assert( + vault.getType() == self.vaultType, + message: "Bridged vault type mismatch - requested: ".concat(self.vaultType.identifier) + .concat(", received: ").concat(vault.getType().identifier) + ) // Deposit the bridged token into the signer's vault self.receiver.deposit(from: <-vault) // Destroy the ScopedFTProvider diff --git a/cadence/transactions/bridge/tokens/bridge_tokens_to_any_cadence_address.cdc b/cadence/transactions/bridge/tokens/bridge_tokens_to_any_cadence_address.cdc index 54d076eb..111e9249 100644 --- a/cadence/transactions/bridge/tokens/bridge_tokens_to_any_cadence_address.cdc +++ b/cadence/transactions/bridge/tokens/bridge_tokens_to_any_cadence_address.cdc @@ -37,7 +37,7 @@ transaction(vaultIdentifier: String, amount: UInt256, recipient: Address) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the Vault type --- */ // @@ -54,11 +54,14 @@ transaction(vaultIdentifier: String, amount: UInt256, recipient: Address) { // // Borrow a reference to the FungibleToken Vault, configuring if necessary let viewResolver = getAccount(tokenContractAddress).contracts.borrow<&{ViewResolver}>(name: tokenContractName) - ?? panic("Could not borrow ViewResolver from FungibleToken contract") + ?? panic("Could not borrow ViewResolver from FungibleToken contract with name" + .concat(tokenContractName).concat(" and address ") + .concat(tokenContractAddress.toString())) let vaultData = viewResolver.resolveContractView( resourceType: self.vaultType, viewType: Type() - ) as! FungibleTokenMetadataViews.FTVaultData? ?? panic("Could not resolve FTVaultData view") + ) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not resolve FTVaultData view for Vault type ".concat(self.vaultType.identifier)) // If the vault does not exist, create it and publish according to the contract's defined configuration if signer.storage.borrow<&{FungibleToken.Vault}>(from: vaultData.storagePath) == nil { signer.storage.save(<-vaultData.createEmptyVault(), to: vaultData.storagePath) @@ -73,7 +76,7 @@ transaction(vaultIdentifier: String, amount: UInt256, recipient: Address) { signer.capabilities.publish(metadataCap, at: vaultData.metadataPath) } self.receiver = getAccount(recipient).capabilities.borrow<&{FungibleToken.Receiver}>(vaultData.receiverPath) - ?? panic("Could not borrow Vault from recipient's account") + ?? panic("Could not borrow FungibleToken Vault from storage path ".concat(vaultData.storagePath.toString())) /* --- Configure a ScopedFTProvider --- */ // @@ -91,7 +94,8 @@ transaction(vaultIdentifier: String, amount: UInt256, recipient: Address) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, @@ -108,7 +112,11 @@ transaction(vaultIdentifier: String, amount: UInt256, recipient: Address) { feeProvider: &self.scopedProvider as auth(FungibleToken.Withdraw) &{FungibleToken.Provider} ) // Ensure the bridged vault is the correct type - assert(vault.getType() == self.vaultType, message: "Bridged vault type mismatch") + assert( + vault.getType() == self.vaultType, + message: "Bridged vault type mismatch - requested: ".concat(self.vaultType.identifier) + .concat(", received: ").concat(vault.getType().identifier) + ) // Deposit the bridged token into the signer's vault self.receiver.deposit(from: <-vault) // Destroy the ScopedFTProvider diff --git a/cadence/transactions/bridge/tokens/bridge_tokens_to_any_evm_address.cdc b/cadence/transactions/bridge/tokens/bridge_tokens_to_any_evm_address.cdc index b5c15b55..b82c6e9a 100644 --- a/cadence/transactions/bridge/tokens/bridge_tokens_to_any_evm_address.cdc +++ b/cadence/transactions/bridge/tokens/bridge_tokens_to_any_evm_address.cdc @@ -45,14 +45,17 @@ transaction(vaultIdentifier: String, amount: UFix64, recipient: String) { // // Borrow a reference to the FungibleToken Vault let viewResolver = getAccount(tokenContractAddress).contracts.borrow<&{ViewResolver}>(name: tokenContractName) - ?? panic("Could not borrow ViewResolver from FungibleToken contract") + ?? panic("Could not borrow ViewResolver from FungibleToken contract with name" + .concat(tokenContractName).concat(" and address ") + .concat(tokenContractAddress.toString())) let vaultData = viewResolver.resolveContractView( resourceType: nil, viewType: Type() - ) as! FungibleTokenMetadataViews.FTVaultData? ?? panic("Could not resolve FTVaultData view") + ) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not resolve FTVaultData view for Vault type ".concat(vaultType.identifier)) let vault = signer.storage.borrow( from: vaultData.storagePath - ) ?? panic("Could not access signer's FungibleToken Vault") + ) ?? panic("Could not borrow FungibleToken Vault from storage path ".concat(vaultData.storagePath.toString())) // Withdraw the requested balance & set a cap on the withdrawable bridge fee self.sentVault <- vault.withdraw(amount: amount) @@ -61,7 +64,7 @@ transaction(vaultIdentifier: String, amount: UFix64, recipient: String) { ) // Determine if the Vault requires onboarding - this impacts the fee required self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.sentVault.getType()) - ?? panic("Bridge does not support this asset type") + ?? panic("Bridge does not support the requested asset type ".concat(vaultIdentifier)) if self.requiresOnboarding { approxFee = approxFee + FlowEVMBridgeConfig.onboardFee } @@ -78,7 +81,8 @@ transaction(vaultIdentifier: String, amount: UFix64, recipient: String) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy, diff --git a/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc b/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc index b60ea6ab..5371e43d 100644 --- a/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc +++ b/cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc @@ -32,7 +32,7 @@ transaction(vaultIdentifier: String, amount: UFix64) { // // Borrow a reference to the signer's COA self.coa = signer.storage.borrow(from: /storage/evm) - ?? panic("Could not borrow COA from provided gateway address") + ?? panic("Could not borrow COA signer's account at path /storage/evm") /* --- Construct the Vault type --- */ // @@ -49,14 +49,17 @@ transaction(vaultIdentifier: String, amount: UFix64) { // // Borrow a reference to the FungibleToken Vault let viewResolver = getAccount(tokenContractAddress).contracts.borrow<&{ViewResolver}>(name: tokenContractName) - ?? panic("Could not borrow ViewResolver from FungibleToken contract") + ?? panic("Could not borrow ViewResolver from FungibleToken contract with name" + .concat(tokenContractName).concat(" and address ") + .concat(tokenContractAddress.toString())) let vaultData = viewResolver.resolveContractView( resourceType: vaultType, viewType: Type() - ) as! FungibleTokenMetadataViews.FTVaultData? ?? panic("Could not resolve FTVaultData view") + ) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not resolve FTVaultData view for Vault type ".concat(vaultType.identifier)) let vault = signer.storage.borrow( from: vaultData.storagePath - ) ?? panic("Could not access signer's FungibleToken Vault") + ) ?? panic("Could not borrow FungibleToken Vault from storage path ".concat(vaultData.storagePath.toString())) // Withdraw the requested balance & set a cap on the withdrawable bridge fee self.sentVault <- vault.withdraw(amount: amount) @@ -65,7 +68,7 @@ transaction(vaultIdentifier: String, amount: UFix64) { ) // Determine if the Vault requires onboarding - this impacts the fee required self.requiresOnboarding = FlowEVMBridge.typeRequiresOnboarding(self.sentVault.getType()) - ?? panic("Bridge does not support this asset type") + ?? panic("Bridge does not support the requested asset type ".concat(vaultIdentifier)) if self.requiresOnboarding { approxFee = approxFee + FlowEVMBridgeConfig.onboardFee } @@ -82,7 +85,8 @@ transaction(vaultIdentifier: String, amount: UFix64) { // Copy the stored Provider capability and create a ScopedFTProvider let providerCapCopy = signer.storage.copy>( from: FlowEVMBridgeConfig.providerCapabilityStoragePath - ) ?? panic("Invalid Provider Capability found in storage.") + ) ?? panic("Invalid FungibleToken Provider Capability found in storage at path " + .concat(FlowEVMBridgeConfig.providerCapabilityStoragePath.toString())) let providerFilter = ScopedFTProviders.AllowanceFilter(approxFee) self.scopedProvider <- ScopedFTProviders.createScopedFTProvider( provider: providerCapCopy,