trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.69k stars 1.52k forks source link

TON: PreImage issues #3797

Open enriquesouza opened 2 months ago

enriquesouza commented 2 months ago

When I am building a transaction input it asks for the private key, it has no sender, but the transfer.

I am not passing the private key, since we sign it externally using TSS, so I call the preImage method, therefore it returns it empty.

Do we have support for preImage TransactionCompiler.preImageHashes for TON?


public struct TW_TheOpenNetwork_Proto_SigningInput {

    /// The secret private key used for signing (32 bytes).
    public var privateKey: Data

    /// The payload transfer
    public var actionOneof: WalletCore.TW_TheOpenNetwork_Proto_SigningInput.OneOf_ActionOneof?

    public var transfer: WalletCore.TW_TheOpenNetwork_Proto_Transfer

    public var jettonTransfer: WalletCore.TW_TheOpenNetwork_Proto_JettonTransfer

    /// Some formats include enough information to transport fields that were
    /// not known at generation time. When encountered, they are stored here.
    public var unknownFields: SwiftProtobuf.UnknownStorage

    /// The payload transfer
    public enum OneOf_ActionOneof : Equatable {

        case transfer(WalletCore.TW_TheOpenNetwork_Proto_Transfer)

        case jettonTransfer(WalletCore.TW_TheOpenNetwork_Proto_JettonTransfer)

        /// Returns a Boolean value indicating whether two values are equal.
        ///
        /// Equality is the inverse of inequality. For any values `a` and `b`,
        /// `a == b` implies that `a != b` is `false`.
        ///
        /// - Parameters:
        ///   - lhs: A value to compare.
        ///   - rhs: Another value to compare.
        public static func == (a: WalletCore.TW_TheOpenNetwork_Proto_SigningInput.OneOf_ActionOneof, b: WalletCore.TW_TheOpenNetwork_Proto_SigningInput.OneOf_ActionOneof) -> Bool
    }

    /// Creates a new message with all of its fields initialized to their default
    /// values.
    public init()
}
satoshiotomakan commented 2 months ago

Hi @enriquesouza, thank you for opening the issue. We do not support TransactionCompiler functions for TON chain yet. Please feel free to open a PR with the preimage and compile functions.

I'll keep this issue open to keep an eye on the issue.

enriquesouza commented 2 months ago

Thanks, I will have a look at this in a few weeks then.

enriquesouza commented 1 week ago

This week I will start implementing it @satoshiotomakan. I can see that you use C++ and Rust, but It seems new coins are being slowly migrated to rust, is it correct?

satoshiotomakan commented 1 week ago

Hi @enriquesouza, yes that's right, we're actively working on Rust migration. Unfortunately, TON is in C++ yet, so you could either migrate TON to Rust and implement the transaction compiler there, or to implement transaction compiler functionality in C++ at Entry::compile