Error while deploying tutorial & possible bug in tutorial's withdraw()

Hello everyone, two things:

  1. I’ve just stared playing around and unfortunately I came across this message on the first step of Fungible Token tutorial (deploying FungibleToken.cdc on account 0x01):


    Any idea why or how to fix this?

  2. Also, it looks to me that the withdraw() function from Vault resource has a bug (when triggered with amount higher than the actual balance it will safely set balance to zero but it will also create a new Vault with amount created out of thin air).
    I guess to prevent this, Provider or Vault itself should have additional pre-condition like:

        pre {
            self.balance >= amount:
                "Balance must be equal or higher than the withdrawal amount"
        }

Or am I missing something? (couldn’t test this myself because of the issue above).

tagging @flowjosh and @MaxStarka

@Kalin you are correct that it would need that pre-condition. It will fail if the amount is greater than the balance anyway because it would underflow, but it is better to include as a precondition so there are better error messages. It is included in the Flow FungibleToken standard here

We’re looking into the graphQL bug. :+1: