F
Flow3mo ago
joshua

joshua | Flow (2024-04-01)

[C1.0] FlowToken.Vault implements the FungibleToken.Vault interface. If I have a FlowToken.Vault in storage, should I be able to borrow a &{FungibleToken.Vault} reference from it using:
signer.storage.borrow<&{FungibleToken.Vault}>(from: /storage/flowTokenVault)
signer.storage.borrow<&{FungibleToken.Vault}>(from: /storage/flowTokenVault)
I could have sworn I was told that it would be possible in Cadence 1.0, but I'm trying right now and it is not working
10 Replies
Needle
Needle3mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
joshua
joshua3mo ago
yeah I am getting this error:
Execution failed:
error: assertion failed: given value is: I.Test.Test.TransactionResult(error: I.Test.Test.Error(message: "[Error Code: 1101] error caused by: 1 error occurred:\n\t* transaction execute failed: [Error Code: 1101] cadence runtime error: Execution failed:\nerror: failed to force-cast value: expected type `{FungibleToken.Vault}`, got `FlowToken.Vault`\n --> a989cb4c9b7010782b78724f66abae88e6a90490d35bf987521fbcce1b38e265:19:11\n |\n19 | if signer.storage.borrow<&{FungibleToken.Vault}>(from: vaultPath) == nil {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n"), status: I.Test.Test.ResultStatus(rawValue: 1))
--> tests/test_example_nft.cdc:64:4
Execution failed:
error: assertion failed: given value is: I.Test.Test.TransactionResult(error: I.Test.Test.Error(message: "[Error Code: 1101] error caused by: 1 error occurred:\n\t* transaction execute failed: [Error Code: 1101] cadence runtime error: Execution failed:\nerror: failed to force-cast value: expected type `{FungibleToken.Vault}`, got `FlowToken.Vault`\n --> a989cb4c9b7010782b78724f66abae88e6a90490d35bf987521fbcce1b38e265:19:11\n |\n19 | if signer.storage.borrow<&{FungibleToken.Vault}>(from: vaultPath) == nil {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n"), status: I.Test.Test.ResultStatus(rawValue: 1))
--> tests/test_example_nft.cdc:64:4
This is in my automated tests in the flow-nft repo maybe there is something about my setup that is wrong. maybe I'm using two different FungibleToken contracts or something yeah I think it is because I was using different FungibleToken versions, but that brings up another question. I'm trying to import the pre-deployed emulator FungibleToken from 0xee82856bf20e2aa6 in the cadence testing framework, but it is telling me that there is nothing at that address
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
joshua
joshua3mo ago
but I know that is the correct address in the emulator because I use it in all my Go tests
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
joshua
joshua3mo ago
does the cadence testing framework emulator have different addresses or something?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
joshua
joshua3mo ago
Is there a list of which contracts are deployed to which addresses somewhere?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View