Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant get an address of ETC #39

Open
danilkharlan opened this issue Nov 20, 2024 · 14 comments
Open

Cant get an address of ETC #39

danilkharlan opened this issue Nov 20, 2024 · 14 comments
Assignees
Labels
awaiting customer Further information has been requested investigation Investigation needed

Comments

@danilkharlan
Copy link

Hello!

We encountered an issue when attempting to retrieve an Ethereum Classic (ETC) address on the Ethereum Classic network in Trust Wallet. The address returned is identical to the one for the BEP20 network, which is incorrect since these networks operate on different protocols and should generate distinct addresses.

@quetool
Copy link
Member

quetool commented Nov 20, 2024

Hello @danilkharlan! Do you mind sharing steps to reproduce?

@danilkharlan
Copy link
Author

1)Connect trust wallet
2)Call get address
3)I got ETC address for BEP20 network,but user can set Etherium Classic network and addresses it this networks is different

How i can specify network when call get address

@quetool
Copy link
Member

quetool commented Nov 21, 2024

But have you added Ethereum Classic network in your dapp in the list of supported networks? Have you switched to it? See docs https://docs.reown.com/appkit/flutter/core/custom-chains

From your steps it feels to me that you connect with Ethereum by default and you just then call getAddress(), therefor you get Ethereum address.

getAddress() is relative to the current selected netowork in your DApp.

@danilkharlan
Copy link
Author

selectedChain value is 61 that equal to Etherium clasic network,but I get BEP20 address(

@quetool
Copy link
Member

quetool commented Nov 21, 2024

Can you share your code?

@danilkharlan
Copy link
Author

danilkharlan commented Nov 21, 2024

showLoader();
    final network = SupportedNetwork.getNetworkFor(
      assetCode: state.assetNetworkModel!.assetCode,
      networkCode: state.assetNetworkModel!.networkCode,
    );
    if (network != null) {
      final res = await getIt<IReownService>().changeNetwork(network);
    }

    final address = getIt<IReownService>().getWalletAddress();

    emitAction(CryptoWithdrawalAction.updateAddress(address, walletType));
    
    
    
    @override
  Future<void> changeNetwork(SupportedNetwork network) async {
    if (!isConnected) return;

    try {
     if (_appKitModal.selectedChain?.chainId == network.chainID) return;
      final chain = ReownAppKitModalNetworks.getNetworkById(
          NetworkUtils.eip155, network.chainID ?? '');
      await _appKitModal.selectChain(chain, switchChain: true);
      _appKitModal.launchConnectedWallet();
      final chainId = int.tryParse(network.chainID ?? '0');
      final result = await _appKitModal.request(
        topic: _appKitModal.session!.topic,
        chainId: _appKitModal.selectedChain!.chainId,
        request: SessionRequestParams(
          method: MethodsConstants.walletSwitchEthChain,
          params: [
            {'chainId': '0x${chainId?.toRadixString(16)}'}
          ],
        ),
      );
    } catch (e) {
      _streamController.addError(e);
    }
  }
  
  
   @override
  String getWalletAddress() =>
      _appKitModal.session?.getAddress(NetworkUtils.eip155) ?? '';
      

@quetool
Copy link
Member

quetool commented Nov 21, 2024

But are you adding Ethereum Classic to ReownAppKitModalNetworks before initializing AppKitModal?

@danilkharlan
Copy link
Author

danilkharlan commented Nov 21, 2024

Here is my init method.Is it correct?

void init({required BuildContext context}) async {
    if (_isInitialized) return;

     ReownAppKitModalNetworks.addSupportedNetworks(
        NetworkUtils.eip155,
        ReownConstants.supportedNetworks,
      );

    _appKitModal = ReownAppKitModal(
      context: context,
      projectId: ReownConstants.projectId,
      enableAnalytics: true,
      logLevel: LogLevel.debug,
      includedWalletIds: {
        ReownConstants.trustWalletId,
        ReownConstants.metaMaskWalletId,
      },
      metadata: PairingMetadata(
        name: ReownConstants.appName,
        description: 'Mobile app',
        url: """",
        icons: [""""],
        redirect: Redirect(native: """""),
      ),
    );

    // Set up listeners for modal events
    _appKitModal.onModalConnect.subscribe((ModalConnect? event) {
      notifyListeners('onModalConnect');
      _onConnect?.call();
    });
    _appKitModal.onModalUpdate
        .subscribe((ModalConnect? event) => notifyListeners('onModalUpdate'));
    _appKitModal.onModalNetworkChange.subscribe(
        (ModalNetworkChange? event) => notifyListeners('onModalNetworkChange'));
    _appKitModal.onModalDisconnect.subscribe(
        (ModalDisconnect? event) => notifyListeners('onModalDisconnect'));
    _appKitModal.onModalError
        .subscribe((ModalError? event) => notifyListeners('onModalError'));
    _appKitModal.onSessionExpireEvent.subscribe(
        (SessionExpire? event) => notifyListeners('onSessionExpireEvent'));
    _appKitModal.onSessionUpdateEvent.subscribe(
        (SessionUpdate? event) => notifyListeners('onSessionUpdateEvent'));
    _appKitModal.onSessionEventEvent.subscribe(
        (SessionEvent? event) => notifyListeners('onSessionEventEvent'));
    _appKitModal.appKit!.core.relayClient.onRelayClientConnect.subscribe(
        (EventArgs? event) => notifyListeners('onRelayClientConnect'));
    _appKitModal.appKit!.core.relayClient.onRelayClientError
        .subscribe((EventArgs? event) => notifyListeners('onRelayClientError'));
    _appKitModal.appKit!.core.relayClient.onRelayClientDisconnect.subscribe(
        (EventArgs? event) => notifyListeners('onRelayClientDisconnect'));

    try {
      await _appKitModal.init();
      final list = _appKitModal.appKit?.authKeys.storage.getAll() as List<Map>?;
      if (selectedWallet == null) {
        for (final map in list ?? []) {
          final listing = map['listing'];
          if (listing != null) {
            final info = ReownAppKitModalWalletInfo.fromJson(map);
            _appKitModal.selectWallet(info);
            _appKitModal.reconnectRelay();
          }
        }
      }

      _isInitialized = true;
      notifyListeners('isInitialized');
    } catch (e) {
      notifyListeners('isInitialized');
    }
  }

@quetool
Copy link
Member

quetool commented Nov 21, 2024

Thanks! Can you explain again the issue? Cause as far as I know Ethereum Classica and Ethereum Mainnet uses the same address format. Furthermore, the addresses depending on the network are given by the connected wallet (Trust in this case) and not by AppKit. I'm a bit lost, sorry...

@danilkharlan
Copy link
Author

Yes,you are right!
In looks weird,but ETC has different addresses in networks...

@quetool
Copy link
Member

quetool commented Nov 21, 2024

Have you tried a different wallet? Maybe it's just a Trust issue?

@danilkharlan
Copy link
Author

In metamask the same addresses,but in trust different
can you handle it?

@quetool
Copy link
Member

quetool commented Nov 21, 2024

Sorry, seems to be an issue on Trust side. We, as AppKit don't mange neither keys nor addresses. Essentially we just allow secure communication between dapp and wallet but keys (therefor addresses) are always on wallet side. You can try opening an issue to them https://github.com/trustwallet maybe?

@quetool quetool added the investigation Investigation needed label Nov 21, 2024
@danilkharlan
Copy link
Author

ill investigate it and will back soon

@quetool quetool added the awaiting customer Further information has been requested label Nov 25, 2024
@quetool quetool self-assigned this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting customer Further information has been requested investigation Investigation needed
Projects
None yet
Development

No branches or pull requests

3 participants
@quetool @danilkharlan and others