diff --git a/assets/network_config.json b/assets/network_config.json index 32fd8a98..481ad2e0 100644 --- a/assets/network_config.json +++ b/assets/network_config.json @@ -1,19 +1,20 @@ { - "pubsub_port": "", - "pubsub_bind_address": "", - "bootstrap_addresses": [ - "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", - "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", - "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", - "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", - "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", - "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", - "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", - "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", - "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd" - - ], - "upnp_enabled": true, - "high_water": 300, - "low_water": 150 -} + "pubsub_port": "", + "pubsub_bind_address": "", + "bootstrap_addresses": [ + "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", + "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", + "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", + "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", + "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", + "/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", + "/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", + "/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", + "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd" + ], + "upnp_enabled": true, + "high_water": 300, + "low_water": 150, + "port_seed": 40001, + "auto_dht": true +} \ No newline at end of file diff --git a/assets/sgns_config.json b/assets/sgns_config.json index 77079699..8dd54d14 100644 --- a/assets/sgns_config.json +++ b/assets/sgns_config.json @@ -1,9 +1,9 @@ { "net_id": 144, - "is_processor": true, + "node_type": "Light", "subnet_id": 0, "bootstrap_fullnodes": [ "/dns4/sg-fullnode-1.gnus.ai/tcp/40102/ipfs/12D3KooWRqFHPFz6YptGnt4wLEGsNuWuv5TLN7rdQ9CFJcbHCWZC" ], "authorized_full_node": "8a33bdf1445a68736429d1773be8682362753a0efc6fb9d8b3e8dffe3b74fc91e26b203fd521547a5219eddf1d3ac51fd17a7646c9bca5ef065da131add4e5a2" -} +} \ No newline at end of file diff --git a/lib/account/sdk_account_manager.dart b/lib/account/sdk_account_manager.dart index d9189a3e..e6fbd5a2 100644 --- a/lib/account/sdk_account_manager.dart +++ b/lib/account/sdk_account_manager.dart @@ -7,8 +7,10 @@ import 'package:genius_wallet/bloc/app_bloc.dart'; import 'package:genius_wallet/components/bottom_drawer/responsive_drawer.dart'; import 'package:genius_wallet/components/scaffold/scaffold_helper.dart'; import 'package:genius_wallet/theme/genius_wallet_colors.dart'; +import 'package:genius_wallet/theme/genius_wallet_consts.dart'; import 'package:genius_wallet/utils/breakpoints.dart'; import 'package:genius_wallet/utils/wallet_utils.dart'; +import 'package:qr_flutter/qr_flutter.dart'; /// A widget that shows the currently selected SDK account and opens a drawer /// for managing SDK accounts (select, add, delete). @@ -200,13 +202,46 @@ class SDKAccountManagerButton extends StatelessWidget { child: Text('Set payout address'), onPressed: () => _showSetPayoutAddressDialog(context), ), - if (mnemonic != null) MenuItemButton( - leadingIcon: const Icon(Icons.numbers), - child: Text("Copy mnemonic"), - onPressed: () => { - Clipboard.setData(ClipboardData(text: mnemonic)) - }, - ), + if (mnemonic != null) ...[ + MenuItemButton( + leadingIcon: const Icon(Icons.numbers), + child: Text("Copy mnemonic"), + onPressed: () => { + Clipboard.setData(ClipboardData(text: mnemonic)), + }, + ), + MenuItemButton( + leadingIcon: const Icon(Icons.qr_code), + child: Text("View mnemonic's QR"), + onPressed: () async => { + await showDialog( + context: context, + builder: (ctx) => AlertDialog( + contentPadding: EdgeInsetsGeometry.all(16), + content: SizedBox( + width: GeniusBreakpoints.small * 0.5, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular( + GeniusWalletConsts.borderRadiusCard, + ), + color: Colors.white, + ), + padding: EdgeInsets.all(4), + child: QrImageView(data: mnemonic), + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(ctx).pop(), + child: const Text('Cancel'), + ), + ], + ), + ), + }, + ), + ], ], ) : IconButton( diff --git a/lib/components/desktop_container.dart b/lib/components/desktop_container.dart index 4e48caad..dd82ec37 100644 --- a/lib/components/desktop_container.dart +++ b/lib/components/desktop_container.dart @@ -71,9 +71,7 @@ class DesktopContainer extends StatelessWidget { const Flexible( child: SearchBar( hintText: 'Search ...', - trailing: [ - Icon(Icons.search, color: Colors.grey), - ], + trailing: [Icon(Icons.search, color: Colors.grey)], ), ), const SizedBox(width: 16), diff --git a/lib/components/toast/toast_manager.dart b/lib/components/toast/toast_manager.dart index 54fe23d8..5c2ec3e1 100644 --- a/lib/components/toast/toast_manager.dart +++ b/lib/components/toast/toast_manager.dart @@ -135,7 +135,9 @@ class _AnimatedToastState extends State<_AnimatedToast> child: Align( alignment: isMobile ? Alignment.center : Alignment.topRight, child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: isMobile ? double.infinity : 600), + constraints: BoxConstraints( + maxWidth: isMobile ? double.infinity : 600, + ), child: SlideTransition( position: _slide, child: ToastWidget( diff --git a/lib/dashboard/bridge/bridge_screen.dart b/lib/dashboard/bridge/bridge_screen.dart index d5e48846..97092e3b 100644 --- a/lib/dashboard/bridge/bridge_screen.dart +++ b/lib/dashboard/bridge/bridge_screen.dart @@ -69,7 +69,9 @@ class BridgeScreenState extends State { return SingleChildScrollView( padding: const EdgeInsets.all(16.0), child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: GeniusBreakpoints.medium), + constraints: const BoxConstraints( + maxWidth: GeniusBreakpoints.medium, + ), child: Card( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -143,8 +145,7 @@ class BridgeScreenState extends State { state.selectedNetwork?.chainId ?? 0, contractAddress: fromToken?.address ?? "", rpcUrl: state.selectedNetwork?.rpcUrl ?? "", - address: - state.selectedWallet?.address ?? "", + address: state.selectedWallet?.address ?? "", amountToBurn: value, destinationChainId: toNetwork?.chainId ?? 0, ); @@ -203,20 +204,16 @@ class BridgeScreenState extends State { ? null : () async { final api = context.read(); - final bridgeTokensResponse = await api - .bridgeOut( - sourceChainId: - state.selectedNetwork?.chainId ?? 0, - contractAddress: fromToken?.address ?? "", - rpcUrl: - state.selectedNetwork?.rpcUrl ?? "", - address: - state.selectedWallet?.address ?? "", - amountToBurn: fromAmountController.text, - destinationChainId: - toNetwork?.chainId ?? 0, - shouldMintTokens: true, - ); + final bridgeTokensResponse = await api.bridgeOut( + sourceChainId: + state.selectedNetwork?.chainId ?? 0, + contractAddress: fromToken?.address ?? "", + rpcUrl: state.selectedNetwork?.rpcUrl ?? "", + address: state.selectedWallet?.address ?? "", + amountToBurn: fromAmountController.text, + destinationChainId: toNetwork?.chainId ?? 0, + shouldMintTokens: true, + ); if (!context.mounted) return; @@ -311,7 +308,8 @@ class BridgeScreenState extends State { maxLines: 1, overflow: - TextOverflow.ellipsis, + TextOverflow + .ellipsis, softWrap: true, // Allows wrapping if needed style: const TextStyle( @@ -322,19 +320,21 @@ class BridgeScreenState extends State { ), ), Text( - fromToken?.networkSymbol ?? + fromToken + ?.networkSymbol ?? "", maxLines: 2, // Allows wrapping on small screens overflow: - TextOverflow.ellipsis, + TextOverflow + .ellipsis, softWrap: true, style: TextStyle( fontSize: 14, - color: - cs.onSurfaceVariant, + color: cs + .onSurfaceVariant, ), ), ], @@ -346,10 +346,9 @@ class BridgeScreenState extends State { const Expanded( child: Icon( - Icons - .arrow_forward, - color: Colors - .white70, + Icons.arrow_forward, + color: + Colors.white70, size: 30, ), ), // Arrow Icon @@ -379,7 +378,8 @@ class BridgeScreenState extends State { maxLines: 1, overflow: - TextOverflow.ellipsis, + TextOverflow + .ellipsis, softWrap: true, // Allows wrapping style: const TextStyle( @@ -390,19 +390,21 @@ class BridgeScreenState extends State { ), ), Text( - toNetwork?.name ?? + toNetwork + ?.name ?? "", maxLines: 2, // Allows wrapping on small screens overflow: - TextOverflow.ellipsis, + TextOverflow + .ellipsis, softWrap: true, style: TextStyle( fontSize: 14, - color: - cs.onSurfaceVariant, + color: cs + .onSurfaceVariant, ), ), ], @@ -420,14 +422,12 @@ class BridgeScreenState extends State { /// **Transaction Hash** const Align( - alignment: - Alignment.centerLeft, + alignment: Alignment.centerLeft, child: Text( 'Transaction Hash:', style: TextStyle( fontSize: 14, - fontWeight: - FontWeight.bold, + fontWeight: FontWeight.bold, ), ), ), @@ -439,9 +439,7 @@ class BridgeScreenState extends State { decoration: BoxDecoration( color: Colors.black26, borderRadius: - BorderRadius.circular( - 8, - ), + BorderRadius.circular(8), ), child: Row( children: [ @@ -450,13 +448,11 @@ class BridgeScreenState extends State { bridgeTokensResponse .data ?? "No Hash Available", - style: - const TextStyle( - fontSize: 16, - fontWeight: - FontWeight - .w500, - ), + style: const TextStyle( + fontSize: 16, + fontWeight: + FontWeight.w500, + ), ), ), IconButton( @@ -653,7 +649,9 @@ class BridgeScreenState extends State { Flexible( flex: 2, // Adjust flex values for proportional sizing child: ConstrainedBox( - constraints: const BoxConstraints(maxHeight: 48), // Consistent height for inputs + constraints: const BoxConstraints( + maxHeight: 48, + ), // Consistent height for inputs child: TextField( controller: controller, // Persistent controller style: const TextStyle(fontSize: 16), diff --git a/lib/navigation/router.dart b/lib/navigation/router.dart index 83e34c82..ee69ae6a 100644 --- a/lib/navigation/router.dart +++ b/lib/navigation/router.dart @@ -201,10 +201,7 @@ final geniusWalletRouter = GoRouter( } }, routes: [ - GoRoute( - path: '/dashboard', - builder: (_, _) => const DashboardScreen(), - ), + GoRoute(path: '/dashboard', builder: (_, _) => const DashboardScreen()), GoRoute( path: '/transactions', builder: (_, _) => const TransactionsScreen(), diff --git a/lib/onboarding/existing_wallet/view/import_security_screen.dart b/lib/onboarding/existing_wallet/view/import_security_screen.dart index 2ac0eb61..efd0869a 100644 --- a/lib/onboarding/existing_wallet/view/import_security_screen.dart +++ b/lib/onboarding/existing_wallet/view/import_security_screen.dart @@ -54,7 +54,9 @@ class ImportSecurityScreen extends StatelessWidget { builder: (context, constraints) { return Center( child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: GeniusBreakpoints.small * 0.8), + constraints: BoxConstraints( + maxWidth: GeniusBreakpoints.small * 0.8, + ), child: Column( spacing: 24.0, mainAxisSize: MainAxisSize.min, diff --git a/lib/onboarding/new_wallet/view/verify_recovery_phrase_screen.dart b/lib/onboarding/new_wallet/view/verify_recovery_phrase_screen.dart index 2babb8e2..6eb3c7b1 100644 --- a/lib/onboarding/new_wallet/view/verify_recovery_phrase_screen.dart +++ b/lib/onboarding/new_wallet/view/verify_recovery_phrase_screen.dart @@ -85,7 +85,9 @@ class _VerifyRecoveryPhraseScreenState }, child: Center( child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: GeniusBreakpoints.small), + constraints: const BoxConstraints( + maxWidth: GeniusBreakpoints.small, + ), child: SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/onboarding/view/wallet_creation_screen.dart b/lib/onboarding/view/wallet_creation_screen.dart index 02fa7676..e7ed3f0d 100644 --- a/lib/onboarding/view/wallet_creation_screen.dart +++ b/lib/onboarding/view/wallet_creation_screen.dart @@ -13,7 +13,9 @@ class WalletCreationScreen extends StatelessWidget { backgroundColor: GeniusWalletColors.deepBlue, body: Center( child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: GeniusBreakpoints.small * 2 / 3), + constraints: BoxConstraints( + maxWidth: GeniusBreakpoints.small * 2 / 3, + ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/lib/onboarding/widgets/paste_field.dart b/lib/onboarding/widgets/paste_field.dart index cefadc92..6f1bebb9 100644 --- a/lib/onboarding/widgets/paste_field.dart +++ b/lib/onboarding/widgets/paste_field.dart @@ -50,7 +50,9 @@ class PasteField extends StatelessWidget { ), ?additionalWidget, ConstrainedBox( - constraints: BoxConstraints(maxWidth: MediaQuery.sizeOf(context).width), + constraints: BoxConstraints( + maxWidth: MediaQuery.sizeOf(context).width, + ), child: Text(subtitle, textAlign: TextAlign.left), ), ], diff --git a/lib/settings/settings_screen.dart b/lib/settings/settings_screen.dart index c7bff47d..064446ae 100644 --- a/lib/settings/settings_screen.dart +++ b/lib/settings/settings_screen.dart @@ -372,9 +372,7 @@ class _SettingsScreenState extends State { } return Row( children: [ - Expanded( - child: Text(label), - ), + Expanded(child: Text(label)), Expanded( child: TextFormField( initialValue: entry.value.toString(), diff --git a/lib/submit_job/view/submit_job_screen.dart b/lib/submit_job/view/submit_job_screen.dart index 0ea45896..9b77ef99 100644 --- a/lib/submit_job/view/submit_job_screen.dart +++ b/lib/submit_job/view/submit_job_screen.dart @@ -81,7 +81,9 @@ class SubmitJobScreen extends StatelessWidget { Align( alignment: AlignmentGeometry.topCenter, child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: GeniusBreakpoints.large), + constraints: BoxConstraints( + maxWidth: GeniusBreakpoints.large, + ), child: SingleChildScrollView( padding: const EdgeInsets.all(12.0), child: Column( diff --git a/lib/theme/theme.dart b/lib/theme/theme.dart index 94f15d8c..98110583 100644 --- a/lib/theme/theme.dart +++ b/lib/theme/theme.dart @@ -135,6 +135,7 @@ ThemeData getThemeData() { ), ), ), + dialogTheme: DialogThemeData(actionsPadding: EdgeInsets.all(12)), inputDecorationTheme: InputDecorationTheme( contentPadding: EdgeInsets.all(20), enabledBorder: OutlineInputBorder( diff --git a/packages/genius_api/lib/ffi/genius_api_ffi.dart b/packages/genius_api/lib/ffi/genius_api_ffi.dart index d3a1b220..dc897512 100644 --- a/packages/genius_api/lib/ffi/genius_api_ffi.dart +++ b/packages/genius_api/lib/ffi/genius_api_ffi.dart @@ -18,22 +18,16 @@ class NativeLibrary { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - /// @brief Inits the SDK with saved settings (no private key — uses existing wallet). + /// @brief Inits the SDK with saved settings (no private key - uses existing wallet). /// If no account exists, creates with a random mnemonic. - /// @param[in] base_path Base path for node data storage. Must contain a `dev_config.json` file. - /// @param[in] autodht Whether to auto-discover DHT peers. - /// @param[in] process Whether to enable processing. - /// @param[in] baseport Base network port for the node. - /// @param[in] is_full_node Whether to run as a full node. + /// @param[in] base_path Base path for node data storage. + /// @param[in] dev_config Developer configuration JSON string (Address, Cut, TokenValue, TokenID). /// @returns Initialization path in case of success, null on failure. ffi.Pointer GeniusSDKInit( ffi.Pointer base_path, - bool autodht, - bool process, - int baseport, - bool is_full_node, + ffi.Pointer dev_config, ) { - return _GeniusSDKInit(base_path, autodht, process, baseport, is_full_node); + return _GeniusSDKInit(base_path, dev_config); } late final _GeniusSDKInitPtr = @@ -41,10 +35,7 @@ class NativeLibrary { ffi.NativeFunction< ffi.Pointer Function( ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Uint16, - ffi.Bool, + ffi.Pointer, ) > >('GeniusSDKInit'); @@ -52,37 +43,21 @@ class NativeLibrary { _GeniusSDKInitPtr.asFunction< ffi.Pointer Function( ffi.Pointer, - bool, - bool, - int, - bool, + ffi.Pointer, ) >(); /// @brief Inits the SDK with an ethereum private key. - /// @param[in] base_path Base path for node data storage. Must contain a `dev_config.json` file. + /// @param[in] base_path Base path for node data storage. + /// @param[in] dev_config Developer configuration JSON string. /// @param[in] eth_private_key Valid HEX ethereum key, supports '0x' prefix. - /// @param[in] autodht Whether to auto-discover DHT peers. - /// @param[in] process Whether to enable processing. - /// @param[in] baseport Base network port for the node. - /// @param[in] is_full_node Whether to run as a full node. /// @returns Initialization path in case of success, null on failure. ffi.Pointer GeniusSDKInitWithKey( ffi.Pointer base_path, + ffi.Pointer dev_config, ffi.Pointer eth_private_key, - bool autodht, - bool process, - int baseport, - bool is_full_node, ) { - return _GeniusSDKInitWithKey( - base_path, - eth_private_key, - autodht, - process, - baseport, - is_full_node, - ); + return _GeniusSDKInitWithKey(base_path, dev_config, eth_private_key); } late final _GeniusSDKInitWithKeyPtr = @@ -91,10 +66,7 @@ class NativeLibrary { ffi.Pointer Function( ffi.Pointer, ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Uint16, - ffi.Bool, + ffi.Pointer, ) > >('GeniusSDKInitWithKey'); @@ -103,29 +75,21 @@ class NativeLibrary { ffi.Pointer Function( ffi.Pointer, ffi.Pointer, - bool, - bool, - int, - bool, + ffi.Pointer, ) >(); + /// @brief Inits the SDK with a BIP39 mnemonic recovery phrase. + /// @param[in] base_path Base path for node data storage. + /// @param[in] dev_config Developer configuration JSON string. + /// @param[in] mnemonic BIP39 mnemonic recovery phrase. + /// @returns Initialization path in case of success, null on failure. ffi.Pointer GeniusSDKInitWithMnemonic( ffi.Pointer base_path, + ffi.Pointer dev_config, ffi.Pointer mnemonic, - bool autodht, - bool process, - int baseport, - bool is_full_node, ) { - return _GeniusSDKInitWithMnemonic( - base_path, - mnemonic, - autodht, - process, - baseport, - is_full_node, - ); + return _GeniusSDKInitWithMnemonic(base_path, dev_config, mnemonic); } late final _GeniusSDKInitWithMnemonicPtr = @@ -134,10 +98,7 @@ class NativeLibrary { ffi.Pointer Function( ffi.Pointer, ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Uint16, - ffi.Bool, + ffi.Pointer, ) > >('GeniusSDKInitWithMnemonic'); @@ -146,99 +107,7 @@ class NativeLibrary { ffi.Pointer Function( ffi.Pointer, ffi.Pointer, - bool, - bool, - int, - bool, - ) - >(); - - /// @brief Inits the SDK with an explicit developer config JSON string and an ethereum private key. - /// @param[in] base_path Base path for node data storage. - /// @param[in] dev_config Developer configuration as a JSON string (overrides dev_config.json). - /// @param[in] eth_private_key Valid HEX ethereum key, supports '0x' prefix. - /// @param[in] autodht Whether to auto-discover DHT peers. - /// @param[in] process Whether to enable processing. - /// @param[in] baseport Base network port for the node. - /// @param[in] is_full_node Whether to run as a full node. - /// @returns Initialization path in case of success, null on failure. - ffi.Pointer GeniusSDKInitWithKeyAndDevConfig( - ffi.Pointer base_path, - ffi.Pointer dev_config, - ffi.Pointer eth_private_key, - bool autodht, - bool process, - int baseport, - bool is_full_node, - ) { - return _GeniusSDKInitWithKeyAndDevConfig( - base_path, - dev_config, - eth_private_key, - autodht, - process, - baseport, - is_full_node, - ); - } - - late final _GeniusSDKInitWithKeyAndDevConfigPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Bool, - ffi.Bool, - ffi.Uint16, - ffi.Bool, - ) - > - >('GeniusSDKInitWithKeyAndDevConfig'); - late final _GeniusSDKInitWithKeyAndDevConfig = - _GeniusSDKInitWithKeyAndDevConfigPtr.asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - bool, - bool, - int, - bool, - ) - >(); - - /// @brief Inits the SDK with minimal configuration (convenience wrapper). - /// @details Equivalent to calling GeniusSDKInitWithKey() with autodht=true, process=true, is_full_node=false. - /// @param[in] base_path Base path for node data storage. - /// @param[in] eth_private_key Valid HEX ethereum key, supports '0x' prefix. - /// @param[in] baseport Base network port for the node. - /// @returns Initialization path in case of success, null on failure. - ffi.Pointer GeniusSDKInitMinimal( - ffi.Pointer base_path, - ffi.Pointer eth_private_key, - int baseport, - ) { - return _GeniusSDKInitMinimal(base_path, eth_private_key, baseport); - } - - late final _GeniusSDKInitMinimalPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Uint16, - ) - > - >('GeniusSDKInitMinimal'); - late final _GeniusSDKInitMinimal = - _GeniusSDKInitMinimalPtr.asFunction< - ffi.Pointer Function( ffi.Pointer, - ffi.Pointer, - int, ) >(); @@ -1333,6 +1202,8 @@ const int __GLIBC_USE_DEPRECATED_GETS = 0; const int __GLIBC_USE_DEPRECATED_SCANF = 0; +const int __GLIBC_USE_C2X_STRTOL = 1; + const int _STDC_PREDEF_H = 1; const int __STDC_IEC_559__ = 1; @@ -1349,7 +1220,7 @@ const int __GNU_LIBRARY__ = 6; const int __GLIBC__ = 2; -const int __GLIBC_MINOR__ = 35; +const int __GLIBC_MINOR__ = 39; const int _SYS_CDEFS_H = 1; @@ -1405,6 +1276,8 @@ const int _BITS_STDINT_INTN_H = 1; const int _BITS_STDINT_UINTN_H = 1; +const int _BITS_STDINT_LEAST_H = 1; + const int INT8_MIN = -128; const int INT16_MIN = -32768; @@ -1507,12 +1380,12 @@ const int WINT_MIN = 0; const int WINT_MAX = 4294967295; +const int __bool_true_false_are_defined = 1; + const int true$ = 1; const int false$ = 0; -const int __bool_true_false_are_defined = 1; - const int GENIUS_SDK_ADDRESS_SIZE = 130; const int GENIUS_SDK_MAX_MNEMONIC_SIZE = 216; diff --git a/packages/genius_api/lib/src/genius_api.dart b/packages/genius_api/lib/src/genius_api.dart index 93717e32..c7b8b75e 100755 --- a/packages/genius_api/lib/src/genius_api.dart +++ b/packages/genius_api/lib/src/genius_api.dart @@ -204,22 +204,23 @@ class GeniusApi { _basePath = await prepareConfigFiles(); final basePathPtr = _basePath.toNativeUtf8(); + final devConfig = await rootBundle.loadString('assets/dev_config.json'); + final devConfigPtr = devConfig.toNativeUtf8(); + ffi.Pointer retVal; if (storedKey.isMnemonic()) { final mnemonic = storedKey.decryptMnemonic(Uint8List(0)); if (mnemonic == null) { debugPrint("Error: failed to decrypt mnemonic"); malloc.free(basePathPtr); + malloc.free(devConfigPtr); return; } final mnemonicPtr = mnemonic.toNativeUtf8(); retVal = _ffiBridgePrebuilt.sgns_lib.GeniusSDKInitWithMnemonic( basePathPtr.cast(), + devConfigPtr.cast(), mnemonicPtr.cast(), - true, - true, - 41001, - false, ); malloc.free(mnemonicPtr); } else { @@ -234,15 +235,13 @@ class GeniusApi { final privateKeyAsPtr = privateKeyAsStr.toNativeUtf8(); retVal = _ffiBridgePrebuilt.sgns_lib.GeniusSDKInitWithKey( basePathPtr.cast(), + devConfigPtr.cast(), privateKeyAsPtr.cast(), - true, - true, - 41001, - false, ); malloc.free(privateKeyAsPtr); } malloc.free(basePathPtr); + malloc.free(devConfigPtr); if (retVal == nullptr) { debugPrint("Error: failed to init SDK"); @@ -313,14 +312,6 @@ class GeniusApi { await loadStoredWallets(); } - Future _ensureOverridesDir(Directory appDocsDir) async { - final overridesDir = Directory('${appDocsDir.path}/$_overridesDirName'); - if (!await overridesDir.exists()) { - await overridesDir.create(recursive: true); - } - return overridesDir; - } - Future> _loadUserOverrides( Directory overridesDir, String fileName, @@ -373,7 +364,11 @@ class GeniusApi { final directory = await getApplicationDocumentsDirectory(); debugPrint('Base path directory: ${directory.path}'); - final overridesDir = await _ensureOverridesDir(directory); + final overridesDir = Directory('${directory.path}/$_overridesDirName'); + if (!await overridesDir.exists()) { + await overridesDir.create(recursive: true); + } + for (final fileName in [ 'network_config.json', 'crdt_config.json', @@ -389,7 +384,9 @@ class GeniusApi { await File('${directory.path}/dev_config.json').writeAsString(devConfig); final sgnsConfig = await rootBundle.loadString('assets/sgns_config.json'); - await File('${directory.path}/sgns_config.json').writeAsString(sgnsConfig); + await File( + '${directory.path}/sgns_config.json', + ).writeAsString(sgnsConfig); await _writeMergedConfig( directory: directory,