coinbase / waas-sdk-react-native

Coinbase Wallet as a Service (WaaS) SDK for React Native. Enables MPC Operations for iOS and Android Devices.
https://docs.cloud.coinbase.com/waas
Other
232 stars 105 forks source link

[rfc] Native iOS SDK #54

Closed jbrower95 closed 11 months ago

jbrower95 commented 11 months ago

Native iOS SDK

Changelog:

WARNING

This PR has a few things that can't merge as-is in it.

Layout

ios/swift - The code-home of WaasSdk.podspec, the native iOS sdk. ios/swift/Tests - Tests for the native SDK, exposed via the WaasSdk podspec.

ios/swift/WaasSdk/models - Well-typed models on top of the codegenned V1.* types from Golang. These structs are also extended for the native SDK to make certain operations easier (i.e you can call .run() on MPC operations directly, to always use the correct method to run them..)

ios/react-native - The wrapper library for RN. ios/react-native/Tests - The tests for the RN sdk, exposed via a test scheme on the RN sample app.

Architecture

  1. waas-sdk-react-native (whose name is set to look like a JS package probably), depends on WaasSdk (the native iOS waas pod).
  2. The class names between the two pods are duplicative, for convenience of the reader.
  3. WaasSdk.* uses Combine and Swift futures to perform async operations with the cross-platform Go SDK.
  4. The react-native SDK then rewraps these swift futures using the Operation.swift "bridge" method -- this awaits the future, and passes on either a resolution or rejection to React Native.

Usage

See README.md, but users can directly depend on WaasSdk.podspec from the root of this repo, which will pull in the code from ios/swift. Setup instructions are included.

Testing

Notes / Feedback on M1 setup