@expensify/react-native-wallet 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  package com.expensify.wallet
2
2
 
3
3
  import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.PromiseImpl
4
5
  import com.facebook.react.bridge.ReadableMap
5
- import com.facebook.react.bridge.WritableMap
6
6
  import com.google.android.gms.tapandpay.issuer.UserAddress
7
7
  import com.expensify.wallet.model.CardData
8
8
  import kotlinx.coroutines.Deferred
@@ -45,100 +45,23 @@ object Utils {
45
45
  async {
46
46
  withContext(Dispatchers.IO) {
47
47
  suspendCancellableCoroutine { continuation ->
48
- val promise = object : Promise {
49
- @Deprecated(
50
- "Prefer passing a module-specific error code to JS. Using this method will pass the error code UNSPECIFIED",
51
- replaceWith = ReplaceWith("reject(code, message)")
52
- )
53
- override fun reject(message: String) {
54
- continuation.resumeWithException(
55
- Exception("Error: $message")
56
- )
57
- }
58
-
59
- override fun reject(code: String?, userInfo: WritableMap) {
60
- val errorMessage = "Error: ${code ?: "Unknown code"}\nUserInfo: $userInfo"
61
- continuation.resumeWithException(
62
- Exception(errorMessage)
63
- )
64
- }
65
-
66
- override fun reject(code: String?, message: String?) {
67
- val errorMessage = "Error: ${code ?: "Unknown code"}\nMessage: ${message ?: "No message provided"}"
68
- continuation.resumeWithException(
69
- Exception(errorMessage)
70
- )
71
- }
72
-
73
- override fun reject(code: String?, message: String?, userInfo: WritableMap) {
74
- val errorMessage =
75
- "Error: ${code ?: "Unknown code"}\nMessage: ${message ?: "No message provided"}\nUserInfo: $userInfo"
76
- continuation.resumeWithException(
77
- Exception(errorMessage)
78
- )
79
- }
80
-
81
- override fun reject(code: String?, message: String?, throwable: Throwable?) {
82
- val errorMessage = "Error: ${code ?: "Unknown code"}\nMessage: ${message ?: "No message provided"}"
83
- continuation.resumeWithException(
84
- throwable ?: Exception(errorMessage)
85
- )
86
- }
87
-
88
- override fun reject(code: String?, throwable: Throwable?) {
89
- val errorMessage = "Error: ${code ?: "Unknown code"}"
48
+ val promise = PromiseImpl({ args ->
49
+ val value = args.getOrNull(0)
50
+ if (resultType.isInstance(value)) {
51
+ continuation.resume(value as String)
52
+ } else {
90
53
  continuation.resumeWithException(
91
- throwable ?: Exception(errorMessage)
54
+ RuntimeException("Expected result of type ${resultType.simpleName}, but got ${value?.javaClass?.simpleName}")
92
55
  )
93
56
  }
94
-
95
- override fun reject(code: String?, throwable: Throwable?, userInfo: WritableMap) {
96
- val errorMessage = "Error: ${code ?: "Unknown code"}\nUserInfo: $userInfo"
97
- continuation.resumeWithException(
98
- throwable ?: Exception(errorMessage)
99
- )
100
- }
101
-
102
- override fun reject(
103
- code: String?,
104
- message: String?,
105
- throwable: Throwable?,
106
- userInfo: WritableMap?
107
- ) {
108
- val errorMessage = buildString {
109
- append("Error: ${code ?: "Unknown code"}")
110
- if (message != null) append("\nMessage: $message")
111
- if (userInfo != null) append("\nUserInfo: $userInfo")
112
- }
113
- continuation.resumeWithException(
114
- throwable ?: Exception(errorMessage)
115
- )
116
- }
117
-
118
- override fun reject(throwable: Throwable) {
119
- continuation.resumeWithException(
120
- throwable
121
- )
122
- }
123
-
124
- override fun reject(throwable: Throwable, userInfo: WritableMap) {
125
- val errorMessage = "Exception occurred\nUserInfo: $userInfo"
126
- continuation.resumeWithException(
127
- Exception(errorMessage, throwable)
128
- )
129
- }
130
-
131
- override fun resolve(value: Any?) {
132
- if (resultType.isInstance(value)) {
133
- continuation.resume(value as String)
134
- } else {
135
- continuation.resumeWithException(
136
- RuntimeException("Expected result of type ${resultType.simpleName}, but got ${value?.javaClass?.simpleName}")
137
- )
138
- }
139
- }
140
-
141
- }
57
+ }, { args ->
58
+ val error = args.getOrNull(0) as? ReadableMap
59
+ val code = error?.getString("code") ?: "Unknown code"
60
+ val message = error?.getString("message") ?: "No message provided"
61
+ continuation.resumeWithException(
62
+ Exception("Error: $code\nMessage: $message")
63
+ )
64
+ })
142
65
  getPromiseOperation(promise)
143
66
  }
144
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expensify/react-native-wallet",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "A React Native module designed for seamless integration of Card Push Provisioning into Apple Wallet and Google Wallet, enabling easy and secure addition of payment cards directly from your application.",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "lib/commonjs/index",