Bridge API

Use pallet_wallet_lite to develop the bridging layer to connect third-party apps.

The pallet_wallet_lite module acts as a bridging layer and is developed based on the thrio routing framework. Pallet-lite can be customized according to the framework used by third-party apps.

Pallet Wallet Lite API

Delegate interface and it's implementation relay on third-part APP

abstract class PalletDelegate {

  /// Get language, format: language-country, such as: en-US
  String getLang();

  /// Get device id
  String getDeviceId();

  /// Get the current environment (pallet only has dev and prod environments)
  String getEnv();

  /// Set log proxy
  ILogDelegate getLogDelegate();

  /// Check if biometrics are supported
  Future<bool> checkBiometrics();

  /// Biometric Authentication Results
  Future<bool> authenticateBiometric();

  /// Track event reporting
  void uploadEvent(String eventName, {Map<String, dynamic>? properties});

  /// Check camera permissions
  Future<bool> checkCameraPermission();

  /// Scan pictures from photo albums and identify results
  Future<String?> scanAlbum();

Pallet provides interface for the third-part APP

abstract class PalletModule {
  factory PalletModule() => PalletPalletModuleImpl();

  void setRootNavigatorKey(GlobalKey<NavigatorState> rootNavigatorKey);

  /// Configure AppDelegate, cold start must call
  void setPalletDelegate(PalletDelegate delegate);

  /// Lazy loading calls to Pallet services
  Future<void> ensureInited(Object? params);

  PalletDelegate get delegate;

  /// Asynchronous initialization: handle non-time-consuming operations necessary on cold start
  Future<void> onModuleAsyncInit(Object? params);

  /// Jump to the wallet homepage by routing
  Future<void> enterPalletHome(BuildContext context);

  /// Get the list of Pallet wallets
  Future<List<BWWallet>> getWalletList({BuildContext? context});

  /// Switch wallet
  Future<void> switchWallet({BuildContext? context, required String walletId});

  /// Get current selected wallet
  Future<String?> getCurrentWallet({BuildContext? context});

  /// Get a list of currently supported blockchains
  Future<List<BWBlockChain>> getChainList({BuildContext? context});

  /// Delete MPC wallet (jump wallet management page)
  Future<void> deleteWallet({BuildContext? context, required String walletId});

  /// Create MPC wallet (jump wallet creation & restoration page)
  Future<void> gotoCreateWallet({BuildContext? context, String? targetUrl});

  /// Create a MPC wallet and open it through a dialog
  Future<void> gotoWalletCreateByDialog({BuildContext? context, String? targetUrl});

  /// Return wallet Homepage as widget
  Future<Widget> walletHome({BuildContext? context});

  /// Jump to wallet settings page
  Future<void> gotoUserSettings({BuildContext? context});

  /// Message signature
  Future<void> signPersonalMessage(
      {BuildContext? context,
      required String walletId,
      required int chainId,
      required String msg,
      Function({dynamic result, bool success})? onFinish});

  /// Typed signature
  Future<void> signTypedMessage(
      {BuildContext? context,
      required String walletId,
      required int chainId,
      required String msg,
      required String raw,
      required Eip712TypedVersion version,
      Function({dynamic result, bool success})? onFinish});

  /// Transcation signature
  Future<void> signTransaction(
      {BuildContext? context,
      required String walletId,
      required int chainId,
      required String from,
      required String to,
      String? gas,
      String? gasPrice,
      String? value,
      String? data,
      Function({dynamic result, bool success})? onFinish});

Last updated