Closed rsrbk closed 1 year ago
Ideally we would like to replicate this Solidity code from Swift/Kotlin:
This part is still debatable, I'm not sure whether it's better to work with smart contract source code on the client or wallet-core.
It is a good practice to limit wallet-core to basic crypto functionality without specific implementations (for example without storing the exact bytecode of ERC1967Proxy.sol smart contract). On the other side, when integrating Thorswap we put lots of their specific smart contract details and logic into the Wallet Core, making it easy to use from the clients and avoiding duplicating code on iOS/Android/Web.
TLDR; this feature is needed to calculate #3 parameter (initHash) for https://github.com/trustwallet/wallet-core/issues/2869
Is your feature request related to a problem? Please describe.
Wallet Core already has some basic ABI encoding support. The support is currently limited to smart contract functions, represented by
EthereumAbiFunction
which is initialized from a string (function name).Describe the solution you'd like
We would like to have something similar to
EthereumAbiFunction
, only for smart contracts deployment. It could be calledEthereumAbiContract
and initialized with either bytecode or string source code (both are acceptible). Then we can add constructor parameters in the same way as adding function parameters toEthereumAbiFunction
. At the end we want to be able to get the final bytes by callingEthereumAbi.encode(contract: contract)
.It's worth researching whether it makes more sense to keep separate types (
EthereumAbiFunction
andEthereumAbiContract
) or to combine everything into a single type (since their API would be very similar).Ideally we would like to replicate this Solidity code from Swift/Kotlin: https://github.com/eth-infinitism/account-abstraction/blob/5a1ad4072438d9e9f7c934b66464dc05a4b37d02/contracts/samples/SimpleAccountFactory.sol#L43-L51
Here is a test case for the above link:
Describe alternatives you've considered The other alternative is to query on-chain Solidity code which isn't very suitable long term.