Skip to content

Android DEMO not works with new "trust_min.js" #573

@ronaldoguedess

Description

@ronaldoguedess

The new library doesn't work with the Android LoadProviderJs sample found at:
https://github.com/trustwallet/trust-web3-provider/blob/main/android/lib/src/main/res/raw/trust_min.js

It probably needs to be updated, as it’s no longer functioning with the new library provided above.

Here’s the relevant code snippet of the MainActivity:

 private fun loadProviderJs(): String {
        return resources.openRawResource(R.raw.trust_min).bufferedReader().use { it.readText() }
}

private fun loadInitJs(chainId: Int, rpcUrl: String): String {
        val source = """
        (function() {
            var config = {                
                ethereum: {
                    chainId: $chainId,
                    rpcUrl: "$rpcUrl"
                },
                solana: {
                    cluster: "mainnet-beta",
                },
                isDebug: true
            };
            trustwallet.ethereum = new trustwallet.Provider(config);
            trustwallet.solana = new trustwallet.SolanaProvider(config);
            trustwallet.postMessage = (json) => {
                window._tw_.postMessage(JSON.stringify(json));
            }
            window.ethereum = trustwallet.ethereum;
        })();
        """
        return  source
}

Could you please provide the updated version to connect with the new trust_min.js? Additionally, I would like to see how to incorporate TON in the implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions