@circle-fin/w3s-pw-react-native-sdk 1.1.7 → 2.0.0
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.
- package/BARE_REACT_NATIVE_GUIDE.md +397 -0
- package/LICENSE +1 -1
- package/README.md +196 -90
- package/android/build.gradle +43 -126
- package/android/src/main/AndroidManifest.xml +12 -16
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkModule.kt +414 -244
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback.kt +76 -74
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/RecordsHelper.kt +602 -0
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/models/Records.kt +43 -0
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnImageSetter.kt +55 -33
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnLayoutProvider.kt +81 -79
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnViewSetterProvider.kt +93 -63
- package/app.json +8 -0
- package/build/ProgrammablewalletRnSdkModule.d.ts +44 -0
- package/build/ProgrammablewalletRnSdkModule.d.ts.map +1 -0
- package/build/ProgrammablewalletRnSdkModule.js +21 -0
- package/build/ProgrammablewalletRnSdkModule.js.map +1 -0
- package/build/WalletSdk.d.ts +20 -0
- package/build/WalletSdk.d.ts.map +1 -0
- package/build/WalletSdk.js +303 -0
- package/build/WalletSdk.js.map +1 -0
- package/build/bridgeSafe.d.ts +50 -0
- package/build/bridgeSafe.d.ts.map +1 -0
- package/build/bridgeSafe.js +136 -0
- package/build/bridgeSafe.js.map +1 -0
- package/build/index.d.ts +21 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +21 -0
- package/build/index.js.map +1 -0
- package/{lib/typescript/src → build}/types.d.ts +72 -43
- package/build/types.d.ts.map +1 -0
- package/build/types.js +331 -0
- package/build/types.js.map +1 -0
- package/build/utils/securityQuestionUtils.d.ts +43 -0
- package/build/utils/securityQuestionUtils.d.ts.map +1 -0
- package/build/utils/securityQuestionUtils.js +109 -0
- package/build/utils/securityQuestionUtils.js.map +1 -0
- package/expo-module.config.json +11 -0
- package/ios/Array+Extension.swift +17 -15
- package/ios/BridgeHelper.swift +71 -92
- package/ios/{RnWalletSdk+CustomizeAdapter.swift → CustomizeAdapter.swift} +19 -29
- package/ios/ProgrammablewalletRnSdk.podspec +30 -0
- package/ios/ProgrammablewalletRnSdkModule.swift +384 -0
- package/ios/TextConfig.swift +17 -15
- package/ios/TextKey.swift +17 -15
- package/ios/UIApplication+Extension.swift +26 -17
- package/ios/UIColor+Extension.swift +34 -28
- package/ios/UITextField+Extension.swift +31 -0
- package/ios/UIView+Extension.swift +24 -17
- package/package.json +70 -116
- package/plugins/apple-signin-entitlements.js +16 -0
- package/plugins/infoplist-config.js +77 -0
- package/plugins/infoplist-config.md +72 -0
- package/plugins/podfile-modifier.js +84 -0
- package/plugins/podfile-modifier.md +33 -0
- package/plugins/withCopyFiles.js +132 -0
- package/plugins/withCopyFiles.md +81 -0
- package/src/ProgrammablewalletRnSdkModule.ts +68 -38
- package/src/WalletSdk.ts +297 -159
- package/src/bridgeSafe.ts +156 -0
- package/src/index.ts +21 -0
- package/src/types.ts +133 -110
- package/src/utils/securityQuestionUtils.ts +121 -0
- package/COPYRIGHT +0 -10
- package/android/gradle.properties +0 -21
- package/android/src/main/AndroidManifestNew.xml +0 -22
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/BridgeHelper.kt +0 -399
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkPackage.kt +0 -49
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback2.kt +0 -65
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseLogoutCallback.kt +0 -47
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseSocialCallback.kt +0 -53
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/TestHelper.kt +0 -37
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/annotation/ExcludeFromGeneratedCCReport.kt +0 -33
- package/android/src/newarch/ProgrammablewalletRnSdkSpec.kt +0 -29
- package/android/src/oldarch/ProgrammablewalletRnSdkSpec.kt +0 -76
- package/circlefin-w3s-pw-react-native-sdk.podspec +0 -41
- package/ios/EventEmitter.swift +0 -49
- package/ios/ProgrammablewalletRnSdk.h +0 -29
- package/ios/ProgrammablewalletRnSdk.mm +0 -162
- package/ios/ReactNativeEventEmitter.m +0 -27
- package/ios/ReactNativeEventEmitter.swift +0 -37
- package/ios/RnWalletSdk.swift +0 -390
- package/ios/programmablewallet-rn-sdk-Bridging-Header.h +0 -22
- package/lib/commonjs/NativeProgrammablewalletRnSdk.js +0 -24
- package/lib/commonjs/NativeProgrammablewalletRnSdk.js.map +0 -1
- package/lib/commonjs/ProgrammablewalletRnSdkModule.js +0 -38
- package/lib/commonjs/ProgrammablewalletRnSdkModule.js.map +0 -1
- package/lib/commonjs/WalletSdk.js +0 -211
- package/lib/commonjs/WalletSdk.js.map +0 -1
- package/lib/commonjs/index.js +0 -74
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/types.js +0 -342
- package/lib/commonjs/types.js.map +0 -1
- package/lib/module/NativeProgrammablewalletRnSdk.js +0 -19
- package/lib/module/NativeProgrammablewalletRnSdk.js.map +0 -1
- package/lib/module/ProgrammablewalletRnSdkModule.js +0 -31
- package/lib/module/ProgrammablewalletRnSdkModule.js.map +0 -1
- package/lib/module/WalletSdk.js +0 -203
- package/lib/module/WalletSdk.js.map +0 -1
- package/lib/module/index.js +0 -18
- package/lib/module/index.js.map +0 -1
- package/lib/module/types.js +0 -334
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts +0 -28
- package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts.map +0 -1
- package/lib/typescript/src/ProgrammablewalletRnSdkModule.d.ts +0 -3
- package/lib/typescript/src/ProgrammablewalletRnSdkModule.d.ts.map +0 -1
- package/lib/typescript/src/WalletSdk.d.ts +0 -3
- package/lib/typescript/src/WalletSdk.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -4
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/src/NativeProgrammablewalletRnSdk.ts +0 -77
- package/src/index.tsx +0 -29
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk
|
|
17
|
-
|
|
18
|
-
import android.content.Context
|
|
19
|
-
import android.graphics.Color
|
|
20
|
-
import android.graphics.Typeface
|
|
21
|
-
import android.text.TextUtils
|
|
22
|
-
import android.util.Log
|
|
23
|
-
import circle.programmablewallet.sdk.api.ApiError
|
|
24
|
-
import circle.programmablewallet.sdk.api.ExecuteWarning
|
|
25
|
-
import circle.programmablewallet.sdk.presentation.IconTextConfig
|
|
26
|
-
import circle.programmablewallet.sdk.presentation.Resource
|
|
27
|
-
import circle.programmablewallet.sdk.presentation.SecurityQuestion
|
|
28
|
-
import circle.programmablewallet.sdk.presentation.SettingsManagement
|
|
29
|
-
import circle.programmablewallet.sdk.presentation.TextConfig
|
|
30
|
-
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
31
|
-
import com.circlefin.programmablewalletrnsdk.pwcustom.RnImageSetter
|
|
32
|
-
import com.facebook.react.bridge.Arguments
|
|
33
|
-
import com.facebook.react.bridge.ReadableArray
|
|
34
|
-
import com.facebook.react.bridge.ReadableMap
|
|
35
|
-
import com.facebook.react.bridge.WritableArray
|
|
36
|
-
import com.facebook.react.bridge.WritableMap
|
|
37
|
-
import java.lang.reflect.Modifier
|
|
38
|
-
|
|
39
|
-
object BridgeHelper {
|
|
40
|
-
private val TAG = BridgeHelper::class.java.simpleName
|
|
41
|
-
val typefaceMap: MutableMap<String?, Typeface?> = HashMap()
|
|
42
|
-
@ExcludeFromGeneratedCCReport
|
|
43
|
-
var questionsForTest: Array<SecurityQuestion?>? = null
|
|
44
|
-
@ExcludeFromGeneratedCCReport
|
|
45
|
-
var dismissOnCallbackForTest: MutableMap<Int, Boolean>? = null
|
|
46
|
-
|
|
47
|
-
@ExcludeFromGeneratedCCReport
|
|
48
|
-
fun objectToMap(obj: ExecuteWarning?): WritableMap {
|
|
49
|
-
val map = Arguments.createMap()
|
|
50
|
-
obj ?: return map
|
|
51
|
-
map.putString("warningString", obj.warningString)
|
|
52
|
-
map.putString("warningType", obj.warningType.toString())
|
|
53
|
-
return map
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@ExcludeFromGeneratedCCReport
|
|
57
|
-
fun objectToMap(obj: ApiError?): WritableMap {
|
|
58
|
-
val map = Arguments.createMap()
|
|
59
|
-
obj ?: return map
|
|
60
|
-
map.putString("code", obj.code.value.toString())
|
|
61
|
-
map.putString("message", obj.message)
|
|
62
|
-
return map
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@ExcludeFromGeneratedCCReport
|
|
66
|
-
@JvmStatic
|
|
67
|
-
fun objectToMap(obj: Any?): WritableMap {
|
|
68
|
-
val map = Arguments.createMap()
|
|
69
|
-
obj ?: return map
|
|
70
|
-
for (field in obj.javaClass.fields) {
|
|
71
|
-
try {
|
|
72
|
-
val name = field.name
|
|
73
|
-
val value = field[obj]
|
|
74
|
-
if (Modifier.isStatic(field.modifiers)) { // skip static field
|
|
75
|
-
continue
|
|
76
|
-
}
|
|
77
|
-
if (!Modifier.isPublic(field.modifiers)) { // skip non-public field
|
|
78
|
-
continue
|
|
79
|
-
}
|
|
80
|
-
if (value == null) {
|
|
81
|
-
map.putNull(name)
|
|
82
|
-
} else if (value is Int) {
|
|
83
|
-
map.putInt(name, value)
|
|
84
|
-
} else if (value is Long) {
|
|
85
|
-
map.putDouble(name, value.toDouble())
|
|
86
|
-
} else if (value is Float) {
|
|
87
|
-
map.putDouble(name, value.toDouble())
|
|
88
|
-
} else if (value is Double) {
|
|
89
|
-
map.putDouble(name, value)
|
|
90
|
-
} else if (value is Boolean) {
|
|
91
|
-
map.putBoolean(name, value)
|
|
92
|
-
} else if (value is String) {
|
|
93
|
-
map.putString(name, value)
|
|
94
|
-
} else if (value.javaClass.isArray) {
|
|
95
|
-
map.putArray(name, objectToArray(value))
|
|
96
|
-
} else if (value.javaClass.isEnum) {
|
|
97
|
-
map.putString(name, (value as Enum<*>).name)
|
|
98
|
-
} else if (!value.javaClass.isPrimitive) {
|
|
99
|
-
map.putMap(name, objectToMap(value))
|
|
100
|
-
} else {
|
|
101
|
-
throw UnsupportedOperationException("Not implemented: $value")
|
|
102
|
-
}
|
|
103
|
-
} catch (e: Exception) {
|
|
104
|
-
Log.w(TAG, "Read field failed", e)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return map
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@ExcludeFromGeneratedCCReport
|
|
111
|
-
private fun objectToArray(array: Any?): WritableArray {
|
|
112
|
-
val arr = Arguments.createArray()
|
|
113
|
-
array ?: return arr
|
|
114
|
-
val n = java.lang.reflect.Array.getLength(array)
|
|
115
|
-
for (i in 0 until n) {
|
|
116
|
-
try {
|
|
117
|
-
val elem = java.lang.reflect.Array.get(array, i)
|
|
118
|
-
if (elem == null) {
|
|
119
|
-
arr.pushNull()
|
|
120
|
-
} else if (elem is Int) {
|
|
121
|
-
arr.pushInt(elem)
|
|
122
|
-
} else if (elem is Long) {
|
|
123
|
-
arr.pushDouble(elem.toDouble())
|
|
124
|
-
} else if (elem is Float) {
|
|
125
|
-
arr.pushDouble(elem.toDouble())
|
|
126
|
-
} else if (elem is Double) {
|
|
127
|
-
arr.pushDouble(elem)
|
|
128
|
-
} else if (elem is Boolean) {
|
|
129
|
-
arr.pushBoolean(elem)
|
|
130
|
-
} else if (elem is String) {
|
|
131
|
-
arr.pushString(elem)
|
|
132
|
-
} else if (elem.javaClass.isArray) {
|
|
133
|
-
arr.pushArray(objectToArray(elem))
|
|
134
|
-
} else if (!elem.javaClass.isPrimitive) {
|
|
135
|
-
arr.pushMap(objectToMap(elem))
|
|
136
|
-
} else {
|
|
137
|
-
throw UnsupportedOperationException("Not implemented: $elem")
|
|
138
|
-
}
|
|
139
|
-
} catch (e: Exception) {
|
|
140
|
-
Log.w(TAG, "Read element failed", e)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return arr
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
fun getColor(colorStr: String?): Int {
|
|
147
|
-
return try {
|
|
148
|
-
if (TextUtils.isEmpty(colorStr)) {
|
|
149
|
-
0
|
|
150
|
-
} else Color.parseColor(colorStr)
|
|
151
|
-
} catch (e: Exception) {
|
|
152
|
-
e.printStackTrace()
|
|
153
|
-
0
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// ReactFontManager.java
|
|
158
|
-
private fun getTypeface(context: Context, fontFamilyName: String?): Typeface? {
|
|
159
|
-
if (TextUtils.isEmpty(fontFamilyName)) {
|
|
160
|
-
return null
|
|
161
|
-
}
|
|
162
|
-
if (typefaceMap[fontFamilyName] != null) {
|
|
163
|
-
return typefaceMap[fontFamilyName]
|
|
164
|
-
}
|
|
165
|
-
val FILE_EXTENSIONS = arrayOf(".ttf", ".otf")
|
|
166
|
-
val FONTS_ASSET_PATH = "fonts/"
|
|
167
|
-
for (fileExtension in FILE_EXTENSIONS) {
|
|
168
|
-
return try {
|
|
169
|
-
val fileName = FONTS_ASSET_PATH +
|
|
170
|
-
fontFamilyName +
|
|
171
|
-
fileExtension
|
|
172
|
-
val typeface = Typeface.createFromAsset(context.assets, fileName)
|
|
173
|
-
typefaceMap[fontFamilyName] = typeface
|
|
174
|
-
typeface
|
|
175
|
-
} catch (e: Exception) {
|
|
176
|
-
// If the typeface asset does not exist, try another extension.
|
|
177
|
-
continue
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return null
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
private fun getColors(readableArray: ReadableArray?): IntArray? {
|
|
184
|
-
if (readableArray == null || readableArray.size() == 0) {
|
|
185
|
-
return null
|
|
186
|
-
}
|
|
187
|
-
val array = IntArray(readableArray.size())
|
|
188
|
-
for (i in 0 until readableArray.size()) {
|
|
189
|
-
array[i] = getColor(readableArray.getString(i))
|
|
190
|
-
}
|
|
191
|
-
return array
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
private fun getTextConfig(context: Context, rnMap: ReadableMap?): TextConfig? {
|
|
195
|
-
rnMap ?: return null
|
|
196
|
-
val textConfig = TextConfig(
|
|
197
|
-
safeGetString(rnMap, "text"),
|
|
198
|
-
getColors(safeGetArray(rnMap, "gradientColors")),
|
|
199
|
-
getTypeface(context, safeGetString(rnMap, "font"))
|
|
200
|
-
)
|
|
201
|
-
textConfig.textColor = getColor(safeGetString(rnMap, "textColor"))
|
|
202
|
-
return textConfig
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
private fun getIconTextConfig(context: Context, rnMap: ReadableMap?): IconTextConfig? {
|
|
206
|
-
rnMap ?: return null
|
|
207
|
-
val v = safeGetString(rnMap, "image")
|
|
208
|
-
return IconTextConfig(RnImageSetter(v), getTextConfig(context, safeGetMap(rnMap, "textConfig")))
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
fun getSettingsManagement(rnMap: ReadableMap?): SettingsManagement? {
|
|
212
|
-
rnMap ?: return null
|
|
213
|
-
val settingsMap = safeGetMap(rnMap, "settingsManagement") ?: return null
|
|
214
|
-
return SettingsManagement(safeGetBoolean(settingsMap, "enableBiometricsPin"))
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private fun safeGetBoolean(map: ReadableMap, key: String): Boolean{
|
|
218
|
-
if (map.hasKey(key)){
|
|
219
|
-
return map.getBoolean(key)
|
|
220
|
-
}
|
|
221
|
-
return false
|
|
222
|
-
}
|
|
223
|
-
private fun safeGetString(map: ReadableMap, key: String): String?{
|
|
224
|
-
if (map.hasKey(key)){
|
|
225
|
-
return map.getString(key)
|
|
226
|
-
}
|
|
227
|
-
return null
|
|
228
|
-
}
|
|
229
|
-
private fun safeGetArray(map: ReadableMap, key: String): ReadableArray?{
|
|
230
|
-
if (map.hasKey(key)){
|
|
231
|
-
return map.getArray(key)
|
|
232
|
-
}
|
|
233
|
-
return null
|
|
234
|
-
}
|
|
235
|
-
private fun safeGetMap(map: ReadableMap, key: String): ReadableMap?{
|
|
236
|
-
if (map.hasKey(key)){
|
|
237
|
-
return map.getMap(key)
|
|
238
|
-
}
|
|
239
|
-
return null
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
private fun getTextConfigArray(context: Context, rnArray: ReadableArray?): Array<TextConfig?> {
|
|
243
|
-
rnArray ?: return arrayOfNulls(0)
|
|
244
|
-
val array = arrayOfNulls<TextConfig>(rnArray.size())
|
|
245
|
-
for (i in 0 until rnArray.size()) {
|
|
246
|
-
try {
|
|
247
|
-
array[i] = getTextConfig(context, rnArray.getMap(i))
|
|
248
|
-
} catch (e: Exception) {
|
|
249
|
-
e.printStackTrace()
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return array
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
private fun getIconTextConfigArray(
|
|
256
|
-
context: Context,
|
|
257
|
-
rnArray: ReadableArray?
|
|
258
|
-
): Array<IconTextConfig?> {
|
|
259
|
-
rnArray ?: return arrayOfNulls(0)
|
|
260
|
-
val array = arrayOfNulls<IconTextConfig>(rnArray.size())
|
|
261
|
-
for (i in 0 until rnArray.size()) {
|
|
262
|
-
try {
|
|
263
|
-
array[i] = getIconTextConfig(context, rnArray.getMap(i))
|
|
264
|
-
} catch (e: Exception) {
|
|
265
|
-
e.printStackTrace()
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return array
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
fun getTextConfigsMap(context: Context, rnMap: ReadableMap?): Map<String, Array<TextConfig?>> {
|
|
272
|
-
val map: MutableMap<String, Array<TextConfig?>> = HashMap()
|
|
273
|
-
rnMap ?: return map
|
|
274
|
-
val itor = rnMap.keySetIterator()
|
|
275
|
-
while (itor.hasNextKey()) {
|
|
276
|
-
val key = itor.nextKey()
|
|
277
|
-
try {
|
|
278
|
-
map[key] = getTextConfigArray(context, rnMap.getArray(key))
|
|
279
|
-
} catch (e: Exception) {
|
|
280
|
-
e.printStackTrace()
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return map
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
fun getTextConfigMap(context: Context, rnMap: ReadableMap?): Map<String, TextConfig> {
|
|
287
|
-
val map: MutableMap<String, TextConfig> = HashMap()
|
|
288
|
-
rnMap ?: return map
|
|
289
|
-
val itor = rnMap.keySetIterator()
|
|
290
|
-
while (itor.hasNextKey()) {
|
|
291
|
-
val key = itor.nextKey()
|
|
292
|
-
try {
|
|
293
|
-
getTextConfig(context, rnMap.getMap(key))?.let {
|
|
294
|
-
map[key] = it
|
|
295
|
-
}
|
|
296
|
-
} catch (e: Exception) {
|
|
297
|
-
e.printStackTrace()
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return map
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
fun getIconTextConfigsMap(
|
|
304
|
-
context: Context,
|
|
305
|
-
rnMap: ReadableMap?
|
|
306
|
-
): Map<Resource.IconTextsKey, Array<IconTextConfig?>> {
|
|
307
|
-
val map: MutableMap<Resource.IconTextsKey, Array<IconTextConfig?>> =
|
|
308
|
-
HashMap()
|
|
309
|
-
rnMap ?: return map
|
|
310
|
-
val itor = rnMap.keySetIterator()
|
|
311
|
-
while (itor.hasNextKey()) {
|
|
312
|
-
val key = itor.nextKey()
|
|
313
|
-
try {
|
|
314
|
-
val enumKey: Resource.IconTextsKey = Resource.IconTextsKey.valueOf(key)
|
|
315
|
-
map[enumKey] = getIconTextConfigArray(context, rnMap.getArray(key))
|
|
316
|
-
} catch (e: Exception) {
|
|
317
|
-
e.printStackTrace()
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return map
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
fun getDismissOnCallbackMap(rnMap: ReadableMap?): Map<Int, Boolean> {
|
|
324
|
-
val map: MutableMap<Int, Boolean> = HashMap()
|
|
325
|
-
rnMap ?: return map
|
|
326
|
-
val itor = rnMap.keySetIterator()
|
|
327
|
-
while (itor.hasNextKey()) {
|
|
328
|
-
val key = itor.nextKey()
|
|
329
|
-
try {
|
|
330
|
-
map[Integer.valueOf(key)] = rnMap.getBoolean(key)
|
|
331
|
-
} catch (e: Exception) {
|
|
332
|
-
e.printStackTrace()
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
if (BuildConfig.DEBUG) {
|
|
336
|
-
dismissOnCallbackForTest = map
|
|
337
|
-
}
|
|
338
|
-
return map
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
fun getErrorStringMap(rnMap: ReadableMap?): Map<Int, String> {
|
|
342
|
-
val map: MutableMap<Int, String> = HashMap()
|
|
343
|
-
rnMap ?: return map
|
|
344
|
-
val itor = rnMap.keySetIterator()
|
|
345
|
-
while (itor.hasNextKey()) {
|
|
346
|
-
val key = itor.nextKey()
|
|
347
|
-
try {
|
|
348
|
-
rnMap.getString(key)?.let {
|
|
349
|
-
map[Integer.valueOf(key)] = it
|
|
350
|
-
}
|
|
351
|
-
} catch (e: Exception) {
|
|
352
|
-
e.printStackTrace()
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return map
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
fun reactNativeMapToStringMap(rnMap: ReadableMap?): Map<String, String> {
|
|
359
|
-
val map: MutableMap<String, String> = HashMap()
|
|
360
|
-
rnMap ?: return map
|
|
361
|
-
val itor = rnMap.keySetIterator()
|
|
362
|
-
while (itor.hasNextKey()) {
|
|
363
|
-
val key = itor.nextKey()
|
|
364
|
-
try {
|
|
365
|
-
rnMap.getString(key)?.let {
|
|
366
|
-
map[key] = it
|
|
367
|
-
}
|
|
368
|
-
} catch (e: Exception) {
|
|
369
|
-
e.printStackTrace()
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
return map
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
fun getSecurityQuestions(rnArray: ReadableArray?): Array<SecurityQuestion?> {
|
|
376
|
-
rnArray ?: return arrayOfNulls(0)
|
|
377
|
-
val array = arrayOfNulls<SecurityQuestion>(rnArray.size())
|
|
378
|
-
for (i in 0 until rnArray.size()) {
|
|
379
|
-
val readableMap = rnArray.getMap(i)
|
|
380
|
-
if (readableMap != null) {
|
|
381
|
-
val inputType = safeGetString(readableMap, "inputType")
|
|
382
|
-
val title = safeGetString(readableMap, "title") ?: ""
|
|
383
|
-
if (SecurityQuestion.InputType.datePicker.name != inputType) {
|
|
384
|
-
array[i] = SecurityQuestion(title)
|
|
385
|
-
} else {
|
|
386
|
-
array[i] = SecurityQuestion(
|
|
387
|
-
title,
|
|
388
|
-
SecurityQuestion.InputType.datePicker
|
|
389
|
-
)
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
if (BuildConfig.DEBUG) {
|
|
394
|
-
questionsForTest = array
|
|
395
|
-
}
|
|
396
|
-
return array
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk
|
|
17
|
-
|
|
18
|
-
import com.facebook.react.TurboReactPackage
|
|
19
|
-
import com.facebook.react.bridge.NativeModule
|
|
20
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
21
|
-
import com.facebook.react.module.model.ReactModuleInfo
|
|
22
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
23
|
-
|
|
24
|
-
class ProgrammablewalletRnSdkPackage : TurboReactPackage() {
|
|
25
|
-
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
26
|
-
return if (name == ProgrammablewalletRnSdkModule.NAME) {
|
|
27
|
-
ProgrammablewalletRnSdkModule(reactContext)
|
|
28
|
-
} else {
|
|
29
|
-
null
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
34
|
-
return ReactModuleInfoProvider {
|
|
35
|
-
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
36
|
-
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
37
|
-
moduleInfos[ProgrammablewalletRnSdkModule.NAME] = ReactModuleInfo(
|
|
38
|
-
ProgrammablewalletRnSdkModule.NAME,
|
|
39
|
-
ProgrammablewalletRnSdkModule.NAME,
|
|
40
|
-
false, // canOverrideExistingModule
|
|
41
|
-
false, // needsEagerInit
|
|
42
|
-
true, // hasConstants
|
|
43
|
-
false, // isCxxModule
|
|
44
|
-
isTurboModule // isTurboModule
|
|
45
|
-
)
|
|
46
|
-
moduleInfos
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk
|
|
17
|
-
|
|
18
|
-
import android.util.Log
|
|
19
|
-
import circle.programmablewallet.sdk.api.ApiError
|
|
20
|
-
import circle.programmablewallet.sdk.api.Callback
|
|
21
|
-
import circle.programmablewallet.sdk.api.Callback2
|
|
22
|
-
import circle.programmablewallet.sdk.api.ExecuteWarning
|
|
23
|
-
import com.circlefin.programmablewalletrnsdk.BridgeHelper.objectToMap
|
|
24
|
-
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
25
|
-
import com.facebook.react.bridge.Arguments
|
|
26
|
-
import com.facebook.react.bridge.Promise
|
|
27
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
28
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
29
|
-
|
|
30
|
-
class PromiseCallback2<R> internal constructor(
|
|
31
|
-
private val promise: Promise?,
|
|
32
|
-
private val context: ReactApplicationContext
|
|
33
|
-
) : Callback2<R> {
|
|
34
|
-
|
|
35
|
-
@ExcludeFromGeneratedCCReport
|
|
36
|
-
override fun onError(error: Throwable): Boolean {
|
|
37
|
-
Log.w(TAG, "onError: ", error)
|
|
38
|
-
if (error is ApiError) {
|
|
39
|
-
val isDismiss = java.lang.Boolean.TRUE == ProgrammablewalletRnSdkModule.dismissOnCallbackMap[error.code.value]
|
|
40
|
-
if (isDismiss) {
|
|
41
|
-
promise?.reject(error.code.value.toString(), error.message, error)
|
|
42
|
-
} else {
|
|
43
|
-
val map = objectToMap(error)
|
|
44
|
-
context.getJSModule(
|
|
45
|
-
DeviceEventManagerModule.RCTDeviceEventEmitter::class.java
|
|
46
|
-
)
|
|
47
|
-
.emit(ProgrammablewalletRnSdkModule.EVENT_NAME_ON_ERROR, map)
|
|
48
|
-
}
|
|
49
|
-
return !isDismiss
|
|
50
|
-
} else {
|
|
51
|
-
promise?.reject(RuntimeException(error.message))
|
|
52
|
-
}
|
|
53
|
-
return false
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@ExcludeFromGeneratedCCReport
|
|
57
|
-
override fun onResult(result: R) {
|
|
58
|
-
promise ?: return
|
|
59
|
-
promise.resolve(objectToMap(result))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
companion object {
|
|
63
|
-
private val TAG = PromiseCallback2::class.java.simpleName
|
|
64
|
-
}
|
|
65
|
-
}
|
package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseLogoutCallback.kt
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk
|
|
17
|
-
|
|
18
|
-
import android.util.Log
|
|
19
|
-
import circle.programmablewallet.sdk.api.ApiError
|
|
20
|
-
import circle.programmablewallet.sdk.api.LogoutCallback
|
|
21
|
-
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
22
|
-
import com.facebook.react.bridge.Promise
|
|
23
|
-
|
|
24
|
-
class PromiseLogoutCallback internal constructor(
|
|
25
|
-
private val promise: Promise?,
|
|
26
|
-
) : LogoutCallback {
|
|
27
|
-
|
|
28
|
-
@ExcludeFromGeneratedCCReport
|
|
29
|
-
override fun onError(error: Throwable) {
|
|
30
|
-
Log.w(TAG, "onError: ", error)
|
|
31
|
-
if (error is ApiError) {
|
|
32
|
-
promise?.reject(error.code.value.toString(), error.message, error)
|
|
33
|
-
} else {
|
|
34
|
-
promise?.reject(RuntimeException(error.message))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
override fun onComplete() {
|
|
39
|
-
promise ?: return
|
|
40
|
-
promise.resolve(null)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
companion object {
|
|
45
|
-
private val TAG = PromiseLogoutCallback::class.java.simpleName
|
|
46
|
-
}
|
|
47
|
-
}
|
package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseSocialCallback.kt
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk
|
|
17
|
-
|
|
18
|
-
import android.util.Log
|
|
19
|
-
import circle.programmablewallet.sdk.api.ApiError
|
|
20
|
-
import circle.programmablewallet.sdk.api.Callback
|
|
21
|
-
import circle.programmablewallet.sdk.api.ExecuteWarning
|
|
22
|
-
import circle.programmablewallet.sdk.api.SocialCallback
|
|
23
|
-
import com.circlefin.programmablewalletrnsdk.BridgeHelper.objectToMap
|
|
24
|
-
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
25
|
-
import com.facebook.react.bridge.Arguments
|
|
26
|
-
import com.facebook.react.bridge.Promise
|
|
27
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
28
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
29
|
-
|
|
30
|
-
class PromiseSocialCallback<R> internal constructor(
|
|
31
|
-
private val promise: Promise?,
|
|
32
|
-
) : SocialCallback<R> {
|
|
33
|
-
|
|
34
|
-
@ExcludeFromGeneratedCCReport
|
|
35
|
-
override fun onError(error: Throwable) {
|
|
36
|
-
Log.w(TAG, "onError: ", error)
|
|
37
|
-
if (error is ApiError) {
|
|
38
|
-
promise?.reject(error.code.value.toString(), error.message, error)
|
|
39
|
-
} else {
|
|
40
|
-
promise?.reject(RuntimeException(error.message))
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
override fun onResult(result: R) {
|
|
45
|
-
promise ?: return
|
|
46
|
-
promise.resolve(objectToMap(result))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
companion object {
|
|
51
|
-
private val TAG = PromiseSocialCallback::class.java.simpleName
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk
|
|
17
|
-
|
|
18
|
-
import android.widget.ImageView
|
|
19
|
-
import androidx.appcompat.widget.Toolbar
|
|
20
|
-
|
|
21
|
-
object TestHelper {
|
|
22
|
-
private val TAG = TestHelper::class.java.simpleName
|
|
23
|
-
|
|
24
|
-
fun addTagForTest(iv: ImageView, tag: String) {
|
|
25
|
-
if (!BuildConfig.DEBUG) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
iv.tag = tag
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
fun addTagForTest(toolbar: Toolbar?, tag: String) {
|
|
32
|
-
if (!BuildConfig.DEBUG) {
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
toolbar?.tag = tag
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
-
//
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
//
|
|
5
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
// you may not use this file except in compliance with the License.
|
|
7
|
-
// You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
// See the License for the specific language governing permissions and
|
|
15
|
-
// limitations under the License.
|
|
16
|
-
package com.circlefin.programmablewalletrnsdk.annotation
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @suppress
|
|
20
|
-
*/
|
|
21
|
-
@MustBeDocumented
|
|
22
|
-
@Retention(AnnotationRetention.RUNTIME)
|
|
23
|
-
@Target(
|
|
24
|
-
AnnotationTarget.ANNOTATION_CLASS,
|
|
25
|
-
AnnotationTarget.CLASS,
|
|
26
|
-
AnnotationTarget.FIELD,
|
|
27
|
-
AnnotationTarget.FUNCTION,
|
|
28
|
-
AnnotationTarget.PROPERTY_GETTER,
|
|
29
|
-
AnnotationTarget.PROPERTY_SETTER,
|
|
30
|
-
AnnotationTarget.CONSTRUCTOR,
|
|
31
|
-
AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.PROPERTY
|
|
32
|
-
)
|
|
33
|
-
internal annotation class ExcludeFromGeneratedCCReport
|