solang icon indicating copy to clipboard operation
solang copied to clipboard

Make Solang compiled contracts compatible with Anchor

Open seanyoung opened this issue 3 years ago • 2 comments

Remaining work (who is working on it in parenthesis)

  • [x] Borsh decoding (Lucas)
  • [x] Allow function selector to be overriden with new selector, variable length on Solana. (Sean)
  • [x] Convert IDL file to solidity interface file solana metadata --target solana [-o outputfile] foo.idl (Sean)
  • [x] Use borsh encoding for function arguments calls with overriden selector (provide end to end IDL tests with this) (Sean)
  • [x] Use borsh encoding for events (Lucas)
  • [x] Use borsh encoding for function return values with overriden selector (Sean)
  • [ ] Rewrite contract dispatch code in CFG
  • [ ] Use borsh encoding for ALL function calls and returns values (requires all tests to be fixed)
  • [ ] Do not pass destination/sender account via input, but via accounts
  • [ ] Solang should produce one binary per contract, just like Anchor/Substrate/ewasm (Sean)
  • [ ] Produce IDL for Solana contracts
  • [ ] Write tests using anchor CLI - anchor itself will need work!
  • [ ] Write PDA tests. The seed will have to be passed in manually. Should just work (needs tests)
  • [ ] abi.encode() and abi.decode() should use borsh encoding
  • [ ] Use borsh encoding for Insert::AssertFailure
  • [ ] Update documentation for try ... catch

seanyoung avatar Aug 15 '22 13:08 seanyoung

It is not on this list, but many instructions utilize ABI encoding and need to be modified. One example is Instr::AssertFailure. Its arguments are ABI encoded in emit. That must change if we migrate to Borsh on Solana.

LucasSte avatar Aug 15 '22 13:08 LucasSte

Note that try .. catch also uses abi encoding/decoding but this functionality does not work on Solana anyway. This needs clearer compiler error messages and documentation.

seanyoung avatar Aug 15 '22 14:08 seanyoung