oasisprotocol / sapphire-paratime

The Sapphire ParaTime monorepo.
https://oasisprotocol.org/sapphire
Apache License 2.0
34 stars 24 forks source link

Why is this function returns a `bind.ContractBackend` instead of `WrappedBackend`? Transactor is not available this way. #320

Closed gabkov closed 2 months ago

gabkov commented 2 months ago

https://github.com/oasisprotocol/sapphire-paratime/blob/398f116299fb3bdab421ee81b1e7f0c3aa73136b/clients/go/compat.go#L157

aefhm commented 2 months ago

I think returning WrappedBackend there makes sense? cc @matevz

Unless perhaps you'd prefer recommending usage of NewWrappedBackend instead if users want that functionality.

matevz commented 2 months ago

Generally you shouldn't need WrappedBackend for handling the smart contract (e.g. abigen-generated .go files use bind.ContractBackend in their constructor). If you really need sapphire-specific Transactor, you can simply cast it, for example:

backend, err = sapphire.WrapClient(client, func(digest [32]byte) ([]byte, error) {
  return crypto.Sign(digest[:], myKey)
})
sapphireBackend, ok := backend.(*sapphire.WrappedBackend)
txOpts = sapphireBackend.Transactor(c.fromAddress)
fmt.Println(txOpts.GasPrice.String())