Open denimcodes opened 1 year ago
Hey, thanks for reporting this! I think this is a dupe of #39 which is unresolved, and should have the same (a bit hacky) workaround:
@instruction
def init_pool(
authority: Signer,
pool: Empty[Pool],
token_mint: TokenMint,
token_vault: Empty[TokenAccount]
):
pool = pool.init(
payer=authority,
seeds=["pool", token_mint]
)
token_vault.init(
payer=authority,
mint=token_mint,
authority=pool,
associated=True
)
Here I've renamed empty_pool
to pool
, and initialise it to the same variable.
The way we do init
calls sequentially is a bit confusing and doesn't quite map to what Anchor is doing. There's more detail in my comments on #39 but basically we can't pass anything created in the function (in your case the pool
variable) into an init
call.
But you also can't use authority = empty_pool
, because the Seahorse compiler won't let you use an empty account as an authority that might not have been initialised
So the workaround makes both Anchor and Seahorse happy: Anchor knows what pool
is because it's an argument to the function, Seahorse can see that you're initialising it before using it as authority.
Got it. The workaround is working as expected. Thanks.
So I ran on this issue:
When I use new created account as authority in the same instruction, I get this error.
Here's the code: