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

grpc doesn't connect to all url #205

Open
Imdavyking opened this issue May 27, 2024 · 0 comments
Open

grpc doesn't connect to all url #205

Imdavyking opened this issue May 27, 2024 · 0 comments
Assignees

Comments

@Imdavyking
Copy link

Imdavyking commented May 27, 2024

Generic information

  • Alan.dart version: 0.41.4
  • Application type (web/Flutter): Mobile App Android

Bug description

Alan doesn't not connect to certain grpc url when send cosmos transaction example -> grpc.testnet-croeseid-4.cronos-pos.org, testnet.sentry.chain.grpc.injective.network

Steps to reproduce

  cosmos.NetworkInfo getNetworkInfo() {
    return cosmos.NetworkInfo(
      bech32Hrp: bech32Hrp,
      lcdInfo: cosmos.LCDInfo(host: lcdUrl),
      grpcInfo: cosmos.GRPCInfo(host: grpcUrl),
    );
  }

final networkInfo = getNetworkInfo();
    final uatomToSend = double.parse(amount) * pow(10, decimals());
    final feeD = await getTransactionFee(amount, to) * pow(10, decimals());

    final keyPair = await compute(calculateCosmosKey, {
      mnemonicKey: pref.get(currentMmenomicKey),
      'getCosmosKeys': true,
      "networkInfo": networkInfo,
      'path': path,
    });

    cosmos.Wallet wallet = keyPair;

    final message = bank.MsgSend.create()
      ..fromAddress = wallet.bech32Address
      ..toAddress = to;

    final coin = cosmos.Coin.create()
      ..denom = denom
      ..amount = uatomToSend.toInt().toString();
    message.amount.add(coin);

    final signer = cosmos.TxSigner.fromNetworkInfo(networkInfo);

    final fee = cosmos.Fee();
    fee.gasLimit = 200000.toInt64();
    final feeCoin = cosmos.Coin.create()
      ..denom = denom
      ..amount = feeD.toInt().toString();
    fee.amount.add(feeCoin);

    final tx = await signer.createAndSign(
      wallet,
      [message],
      memo: memo,
      fee: fee,
    );

    final txSender = cosmos.TxSender.fromNetworkInfo(networkInfo);
    final response = await txSender.broadcastTx(tx);

    if (response.isSuccessful) {
      return response.txhash;
    }
    if (kDebugMode) {
      print(response.toString());
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants