Closed berzanorg closed 1 month ago
@berzanorg you're just missing an await
:
const mintTx = await Mina.transaction(userAccount2, async () => {
- token.transfer(userAccount2, userAccount1, UInt64.from(1000))
+ await token.transfer(userAccount2, userAccount1, UInt64.from(1000))
AccountUpdate.fundNewAccount(userAccount2)
})
It seems hard to give consistently good error messages for this problem :/
Here's what happens:
fundNewAccount()
call happens while we are still within the context of the transfer()
callAccountUpdate.fundNewAccount()
creates an account update and tries to push it as a child update of the transfer()
calltransfer()
fully "finalizes" its forest of child account updates, so adding another child creates an error
transfer()
creates an AccountUpdateForest
, and passes it to the internal approveBase()
approveBase()
internally calls TokenContract.forEachUpdate()
which calls this.approve(forest)
, which makes the input forest be the final account update layout of this method call
There was no issue when I was using o1js v0.17.0, but after I updated my project to v1.1.0 it started to throw the error below.
This code works: (fixed version)
But this doesn't work: (old version)
And throws this error,
Error: Cannot push to an immutable forest
.You can replicate the same error just by using a basic custom token contract like below:
Maybe having a more clear error message would make it easier to debug. Or if it is possible, making both of the snippets work like in the previous versions would be very good.