gagliardetto / anchor-go

Generate Go clients from anchor IDLs for Solana blockchain programs
MIT License
153 stars 40 forks source link

Out-of-order signer accounts can cause issues with generated Anchor bindings #9

Open nathanleclaire opened 2 years ago

nathanleclaire commented 2 years ago

I ran into this issue using the code gen because in my Rust struct, the authority which I used to sign a transaction was not listed as the zeroth account, which is what the Solana runtime expects for verification (since the signature is in the zeroth index of the list of sigs). So anchor-go complained about sigs, yet, it worked in the Anchor JS client.

Anchor JS bindings, I think were doing some magic behind the scenes (https://github.com/project-serum/anchor/blob/master/ts/src/program/accounts-resolver.ts#L42 ?) to make the ordering work correctly, perhaps the generated Go code could do something like this as well. But that would also probably complicate the code, so I can definitely see it as unnecessary as well.

gagliardetto commented 2 years ago

Can you serialize to base64 the anchor equivalent of the same transaction? And post it here (or send privately)

nathanleclaire commented 2 years ago

Do you happen to know the code to do that in Anchor JS/TSX? I can get .transaction() off the RPC, but it's giving me some mystery complaints even after signing, setting fee payer, etc