SDK for a crypto wallet based on Kotlin Multiplatform
Stfalcon.com task was to create an SDK for Android and IOS mobile platforms based on Kotlin Multi Platform for a crypto wallet.
One of the tasks was to combine business logic and use the same code base on different platforms. To do this, we used Kotlin Multiplatform technology, which allowed us to use the same business models, processes, queries, internal data processing and encryption on all target platforms.
Combining business logic has allowed:
- use the same methods to obtain and present data;
- identical handling of errors and intermediate states.
For example, high-precision digital values are processed equally on both platforms.
Interfaces have been developed to interact with UI applications, the implementation of which will rigidly define states, data acquisition format and errors.
The development took place in several stages:
- Familiarity with KMM and security requirements.
- Forming, implementing contracts and API requests using apiary.io.
- Development of a common SDK architecture.
- Application architecture development and application SDK integration.
- SDK edits for iOS to work correctly.
Of all the development flows, the most important was the development of the architecture for the SDK. During the development, Clear Architecture was taken using Interactors. We also had to separate the platform-dependent code into a separate submodule with external implementation directly on the platforms. For example, one such separation was the RSA and HMAC modules.
The most difficult step was the integration of the SDK on the platform. The fact is that depending on the version of the Kotlin language, the principle of generating and exporting the iOS module has changed. Previous approaches to generation have been removed as obsolete, and new ones have worked incorrectly. The solution was to generate 2 different modules for different architectures (based on Intel processors and M series processors) and further merge them into a universal module. The final solution was a hybrid project of iOS and Android applications, which used the internal dependencies of both projects from platforms.
The victory was the implementation of its own Coroutine Scope for iOS applications, as iOS and Android platforms have different approaches to working with streams. All queries were wrapped in common interactors used on each of the platforms, which allowed the same data processing and error handling.
We have managed to develop a ready-to-use SDK based on Kotlin Multiplatform. This SDK integrates business logic, encapsulates all internal processes responsible for encryption, storage, and authorization.