0

Hey I'm working on a Eosio blockchain dapp, so for front end I'm using flutter. We have a package Eosdart for connecting flutter to eos blockchain.

Everything was good till here, but the problem comes after this. Actually I'm making a small loan app so it takes lots of float datatype to store at blockchain like interest rate Emi etc. So blockchain part is working properly, problem coming in flutter.

Whenever I'm calling any action on blockchain with flutter app and if that action contains any float value, flutter throws an unhandled exception, saying unknown type : flaot32 Or float64,

After that i looked in the error I find out in eosdart package of flutter for connection blockchain, they have commented the code for float64 and float32 and that's why flutter throwing exception unknown type, coz it's not getting that float32 or float64 datatype

This is what I think about this error.

Please suggest if anyone have any idea,

Also if I'm correct as I said then developers should know about this error and improve this, coz float datatype is necessity without it can't build the app

Also,i tried removing float datatype and putting int and then when i run the same code it runs perfectly

THIS IS MY CODE FOR CALLING ACTION


  void requestLoan() {
    List<eos.Authorization> auth = [
      eos.Authorization()
        ..actor = 'guru11111111'
        ..permission = 'active'
    ];
    Map data = {
      'borrower': 'borrower3',
      'uwr_name': widget.lenderDetailList[widget.index]['acc_name'],
      'loan_amnt': loanAmountController.text,
      'interest_rate': widget.lenderDetailList[widget.index]['interest_rate'],
      'loan_duration': tenureController.text,
    };

    List<eos.Action> actions = [
      eos.Action()
        ..account = 'microfinance'
        ..name = 'reqloan'
        ..authorization = auth
        ..data = data
    ];

    eos.Transaction transaction = eos.Transaction()..actions = actions;
    _eosClient.pushTransaction(transaction, broadcast: true).then((trx) {
      print(trx);
    });
  }

This is my console eRROR

E/flutter ( 6542): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Unknown type: float32
E/flutter ( 6542): #0      getType (package:eosdart/src/serialize.dart:1149:3)
E/flutter ( 6542): #1      getTypesFromAbi.<anonymous closure> (package:eosdart/src/serialize.dart:1194:20)
E/flutter ( 6542): #2      CastMap.forEach.<anonymous closure> (dart:_internal/cast.dart:286:8)
E/flutter ( 6542): #3      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter ( 6542): #4      CastMap.forEach (dart:_internal/cast.dart:285:13)
E/flutter ( 6542): #5      getTypesFromAbi (package:eosdart/src/serialize.dart:1189:9)
E/flutter ( 6542): #6      EOSClient._getContract (package:eosdart/src/client.dart:275:17)
E/flutter ( 6542): <asynchronous suspension>
E/flutter ( 6542): #7      EOSClient._serializeActions (package:eosdart/src/client.dart:299:33)
E/flutter ( 6542): <asynchronous suspension>
E/flutter ( 6542): #8      EOSClient.getRequiredKeys (package:eosdart/src/client.dart:203:17)
E/flutter ( 6542): <asynchronous suspension>
E/flutter ( 6542): #9      EOSClient._pushTransactionArgs (package:eosdart/src/client.dart:337:15)
E/flutter ( 6542): <asynchronous suspension>
E/flutter ( 6542): #10     EOSClient.pushTransaction (package:eosdart/src/client.dart:254:53)
E/flutter ( 6542): <asynchronous suspension>
E/flutter ( 6542): #11     _LenderInfoWidgetState.requestLoan (package:new_microfinance/lender_info_widget.dart:470:16)
E/flutter ( 6542): #12     _LenderInfoWidgetState._modalBottomSheetMenu.<anonymous closure>.<anonymous closure> (package:new_microfinance/lender_info_widget.dart:410:31)
E/flutter ( 6542): #13     _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:654:14)
E/flutter ( 6542): #14     _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:729:32)
E/flutter ( 6542): #15     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 6542): #16     TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
E/flutter ( 6542): #17     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7)
E/flutter ( 6542): #18     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 6542): #19     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter ( 6542): #20     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 6542): #21     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 6542): #22     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 6542): #23     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 6542): #24     _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter ( 6542): #25     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 6542): #26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter ( 6542): #27     _invoke1 (dart:ui/hooks.dart:263:10)
E/flutter ( 6542): #28     _dispatchPointerDataPacket (dart:ui/hooks.dart:172:5)

I know this question is not totally on EOS,flutter also comes in here,but as a whole EOS comes in,so please sugguest anything u.

1

There are is a open issue and a pull-request in the eosdart-repository regarding float32- and float64-serialization, see here: Pull-Request, Issue.

So you probably have to wait for someone to solve the serialization-problem or you have to find a workaround.

Idea for a workaround:

Change the type in your contract from float32/float64 to string and parse string to float within your action with std::atof or something similar. Naturally you have to do the reverse(flaot to string) in your dart-app to pass a string instead of a float to the action.

| improve this answer | |
  • hey do u have any example for this,how to convert string to float ?please help if u know @cmadh – guruprakash gupta Nov 25 '19 at 6:31
0

The support for float32 and float64 was added in v0.4.4

https://github.com/primes-network/eosdart/releases/tag/v0.4.4

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.