import 'dart:ffi'; import 'package:cw_haven/api/signatures.dart'; import 'package:cw_haven/api/types.dart'; import 'package:cw_haven/api/haven_api.dart'; import 'package:cw_haven/api/structs/haven_balance_row.dart'; import 'package:cw_haven/api/structs/haven_rate.dart'; import 'asset_types.dart'; List getHavenFullBalance({int accountIndex = 0}) { final size = assetTypesSizeNative(); final balanceAddressesPointer = getHavenFullBalanceNative(accountIndex); final balanceAddresses = balanceAddressesPointer.asTypedList(size); return balanceAddresses .map((addr) => Pointer.fromAddress(addr).ref) .toList(); } List getHavenUnlockedBalance({int accountIndex = 0}) { final size = assetTypesSizeNative(); final balanceAddressesPointer = getHavenUnlockedBalanceNative(accountIndex); final balanceAddresses = balanceAddressesPointer.asTypedList(size); return balanceAddresses .map((addr) => Pointer.fromAddress(addr).ref) .toList(); } List getRate() { updateRateNative(); final size = sizeOfRateNative(); final ratePointer = getRateNative(); final rate = ratePointer.asTypedList(size); return rate .map((addr) => Pointer.fromAddress(addr).ref) .toList(); } final getHavenFullBalanceNative = havenApi .lookup>('get_full_balance') .asFunction(); final getHavenUnlockedBalanceNative = havenApi .lookup>('get_unlocked_balance') .asFunction(); final getRateNative = havenApi .lookup>('get_rate') .asFunction(); final sizeOfRateNative = havenApi .lookup>('size_of_rate') .asFunction(); final updateRateNative = havenApi .lookup>('update_rate') .asFunction();