zeroxkey_core 0.1.0
zeroxkey_core: ^0.1.0 copied to clipboard
Platform-agnostic core for the ZeroXKey SDK (domain, data, network, providers, DI).
zeroxkey_core #
Platform-agnostic core for the ZeroXKey SDK. Pure Dart (no Flutter imports) so it can be unit-tested in isolation and reused across runtimes.
It houses the architectural layers that sit between the generated protocol
client (zeroxkey_http) and the Flutter presentation layer
(zeroxkey_sdk_flutter):
- errors -
ZeroXKeyExceptionhierarchy (NetworkException,TimeoutException,ApiException,AuthException,SigningException,StateException). The wire-levelZeroXKeyRequestErroris mapped toApiExceptionat the data boundary. - config / provider - immutable
ZeroXKeyConfiguration,NetworkOptions, and theBackendProvideradapter (ZeroXKeyBackendProviderdefaults toapi.0xkey.io/authproxy.0xkey.ioand the0xkey_hpkeinfo string). - network -
MiddlewareHttpTransportdecorates anyHttpTransportwith request tracing (X-Trace-Id), exponential-backoffRetryPolicy(connection errors only; timeouts are never retried), bounded timeouts, andApiErrorMapper. - signing -
SignerandKeyStorestrategy ports. - domain / data - entities, repository interfaces, use cases
(
SignMessageUseCase), and their implementations backed byZeroXKeyClient. - di -
ZeroXKeyContainer, a hand-written composition root (no third-party DI).
Usage #
zeroxkey_core is consumed by zeroxkey_sdk_flutter; most apps do not depend on
it directly. To assemble the graph:
import 'package:zeroxkey_core/zeroxkey_core.dart';
final container = ZeroXKeyContainer(
configuration: const ZeroXKeyConfiguration(
backend: ZeroXKeyBackendProvider(),
),
clientResolver: () => myActiveZeroXKeyClient,
);
// Inject the decorated transport into the generated client:
final client = ZeroXKeyClient(
config: THttpConfig(baseUrl: 'https://api.0xkey.io'),
stamper: mySigner, // any Signer (a TStamper)
transport: container.transport,
);
// Delegate domain operations:
final wallets = await container.walletRepository
.fetchWallets(organizationId: 'org-id');
Tests #
dart test