@walletconnect/react-native-compat 2.18.1-canary-ca-1 → 2.18.1-canary-ca-3
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/android/build.gradle
CHANGED
@@ -123,7 +123,7 @@ dependencies {
|
|
123
123
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0' // Latest stable version
|
124
124
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0' // For Dispatchers.Main
|
125
125
|
implementation 'com.google.code.gson:gson:2.9.0'
|
126
|
-
implementation
|
126
|
+
implementation 'com.github.reown-com:yttrium:0.8.19'
|
127
127
|
}
|
128
128
|
|
129
129
|
if (isNewArchitectureEnabled()) {
|
package/android/src/main/java/com/walletconnect/reactnativemodule/RNWalletConnectModuleModule.kt
CHANGED
@@ -3,10 +3,12 @@ package com.walletconnect.reactnativemodule
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
4
4
|
import com.facebook.react.bridge.ReactMethod
|
5
5
|
import com.facebook.react.bridge.Promise
|
6
|
+
import com.facebook.react.bridge.ReadableArray
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
6
8
|
import android.content.pm.PackageManager
|
7
9
|
import uniffi.uniffi_yttrium.ChainAbstractionClient
|
10
|
+
import uniffi.yttrium.PrepareResponse
|
8
11
|
import kotlinx.coroutines.*
|
9
|
-
import com.facebook.react.bridge.ReadableMap
|
10
12
|
import uniffi.uniffi_yttrium.*
|
11
13
|
import uniffi.yttrium.*
|
12
14
|
import com.google.gson.Gson
|
@@ -61,80 +63,74 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
61
63
|
|
62
64
|
// ------------------------------ Yttrium Chain Abstraction ------------------------------
|
63
65
|
|
64
|
-
private var
|
66
|
+
private var prepareAvailableResultsMap: MutableMap<String, PrepareResponseAvailable> = mutableMapOf()
|
67
|
+
private var prepareDetailedAvailableResultsMap: MutableMap<String, UiFields> = mutableMapOf()
|
68
|
+
private lateinit var client: ChainAbstractionClient
|
65
69
|
|
70
|
+
@OptIn(DelicateCoroutinesApi::class)
|
71
|
+
@ReactMethod
|
72
|
+
override fun initialize(params: ReadableMap, promise: Promise){
|
73
|
+
GlobalScope.launch(Dispatchers.Main) {
|
74
|
+
try {
|
75
|
+
var projectId = params.getString("projectId") as String
|
76
|
+
var sdkVersion = params.getString("sdkVersion") as String
|
77
|
+
var url = params.getString("url") as String
|
78
|
+
|
79
|
+
client = ChainAbstractionClient(projectId, PulseMetadata(url= url, bundleId = "test", packageName = "test package", sdkVersion= sdkVersion, sdkPlatform = "mobile"))
|
80
|
+
promise.resolve(true)
|
81
|
+
} catch (e: Exception) {
|
82
|
+
// In case of an error, reject the promise
|
83
|
+
promise.reject("ERROR", "Yttrium initialize Error:" + e.message, e)
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
66
87
|
|
67
88
|
@ReactMethod
|
68
89
|
override fun prepare(params: ReadableMap, promise: Promise){
|
69
90
|
System.out.println("checkRoute: Hello from YttriumModule")
|
70
91
|
GlobalScope.launch(Dispatchers.Main) {
|
71
92
|
try {
|
72
|
-
var projectId = params.getString("projectId") as String
|
73
93
|
val transactionMap = params.getMap("transaction")
|
74
|
-
|
75
|
-
|
76
|
-
|
94
|
+
|
95
|
+
if(transactionMap === null) {
|
96
|
+
throw Error("no params")
|
97
|
+
}
|
77
98
|
// Extract values from the nested transaction map
|
78
99
|
val chainId = transactionMap.getString("chainId") ?: ""
|
79
|
-
val
|
100
|
+
val input = transactionMap.getString("input") ?: ""
|
80
101
|
val from = transactionMap.getString("from") ?: ""
|
81
102
|
val to = transactionMap.getString("to") ?: ""
|
82
103
|
val value = transactionMap.getString("value") ?: "0"
|
83
|
-
val
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
104
|
+
val result = client.prepare(chainId = chainId, from = from, Call(
|
105
|
+
to= to,
|
106
|
+
value = value,
|
107
|
+
input = input
|
108
|
+
))
|
109
|
+
|
110
|
+
when(result) {
|
88
111
|
is PrepareResponse.Success -> {
|
89
112
|
when (result.v1) {
|
90
|
-
is
|
91
|
-
val availableResult = (result.v1 as
|
92
|
-
|
93
|
-
val gson = Gson()
|
94
|
-
val routesJson: JsonElement = gson.toJsonTree(availableResult)
|
95
|
-
val response = JsonObject()
|
96
|
-
response.addProperty("status", "available")
|
97
|
-
response.add("data", routesJson)
|
98
|
-
promise.resolve(gson.toJson(response))
|
113
|
+
is PrepareResponseSuccess.Available -> {
|
114
|
+
val availableResult = (result.v1 as PrepareResponseSuccess.Available).v1;
|
115
|
+
prepareAvailableResultsMap[availableResult.orchestrationId] = availableResult;
|
99
116
|
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
val gson = Gson()
|
104
|
-
promise.resolve(gson.toJson(response))
|
117
|
+
|
118
|
+
is PrepareResponseSuccess.NotRequired -> {
|
119
|
+
println("not required")
|
105
120
|
}
|
106
121
|
}
|
107
122
|
}
|
108
123
|
is PrepareResponse.Error -> {
|
109
|
-
|
110
|
-
|
111
|
-
"NO_ROUTES_AVAILABLE" -> {
|
112
|
-
val response = JsonObject()
|
113
|
-
response.addProperty("status", "error")
|
114
|
-
response.addProperty("reason", "noRoutesAvailable")
|
115
|
-
val gson = Gson()
|
116
|
-
promise.resolve(gson.toJson(response))
|
117
|
-
}
|
118
|
-
"INSUFFICIENT_FUNDS" -> {
|
119
|
-
val response = JsonObject()
|
120
|
-
response.addProperty("status", "error")
|
121
|
-
response.addProperty("reason", "insufficientFunds")
|
122
|
-
val gson = Gson()
|
123
|
-
promise.resolve(gson.toJson(response))
|
124
|
-
}
|
125
|
-
"INSUFFICIENT_GAS_FUNDS" -> {
|
126
|
-
val response = JsonObject()
|
127
|
-
response.addProperty("status", "error")
|
128
|
-
response.addProperty("reason", "insufficientGasFunds")
|
129
|
-
val gson = Gson()
|
130
|
-
promise.resolve(gson.toJson(response))
|
131
|
-
}
|
132
|
-
}
|
124
|
+
println("prepare error: ")
|
125
|
+
println(result.v1.error)
|
133
126
|
}
|
134
127
|
}
|
128
|
+
println("checkRoute: result: ")
|
129
|
+
println(result)
|
135
130
|
|
136
|
-
|
137
|
-
|
131
|
+
val gson = Gson()
|
132
|
+
val jsonResult = gson.toJson(result)
|
133
|
+
promise.resolve(jsonResult)
|
138
134
|
} catch (e: Exception) {
|
139
135
|
// In case of an error, reject the promise
|
140
136
|
promise.reject("ERROR", "Yttrium checkRoute Error:" + e.message, e)
|
@@ -143,55 +139,73 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
143
139
|
}
|
144
140
|
|
145
141
|
@ReactMethod
|
146
|
-
override fun
|
147
|
-
System.out.println("
|
148
|
-
|
142
|
+
override fun prepareDetailed(params: ReadableMap, promise: Promise){
|
143
|
+
System.out.println("prepareDetailed: Hello from YttriumModule")
|
149
144
|
GlobalScope.launch(Dispatchers.Main) {
|
150
145
|
try {
|
146
|
+
val transactionMap = params.getMap("transaction")
|
151
147
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
148
|
+
if(transactionMap === null) {
|
149
|
+
throw Error("no params")
|
150
|
+
}
|
151
|
+
// Extract values from the nested transaction map
|
152
|
+
val chainId = transactionMap.getString("chainId") ?: ""
|
153
|
+
val input = transactionMap.getString("input") ?: ""
|
154
|
+
val from = transactionMap.getString("from") ?: ""
|
155
|
+
val to = transactionMap.getString("to") ?: ""
|
156
|
+
val value = transactionMap.getString("value") ?: "0"
|
157
|
+
val result = client.prepareDetailed(chainId = chainId, from = from, Call(
|
158
|
+
to= to,
|
159
|
+
value = value,
|
160
|
+
input = input
|
161
|
+
), Currency.USD)
|
162
|
+
|
163
|
+
|
164
|
+
println("prepareDetailed: result: ")
|
165
|
+
println(result)
|
166
|
+
|
167
|
+
when(result) {
|
168
|
+
is PrepareDetailedResponse.Success -> {
|
158
169
|
when (result.v1) {
|
159
|
-
is
|
160
|
-
val
|
161
|
-
|
162
|
-
response.addProperty("createdAt", result.v1.createdAt.toString())
|
163
|
-
val gson = Gson()
|
164
|
-
promise.resolve(gson.toJson(response))
|
170
|
+
is PrepareDetailedResponseSuccess.Available -> {
|
171
|
+
val availableResult = (result.v1 as PrepareDetailedResponseSuccess.Available).v1
|
172
|
+
prepareDetailedAvailableResultsMap[availableResult.routeResponse.orchestrationId] = availableResult
|
165
173
|
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
is StatusResponse.Error -> {
|
170
|
-
when (result.v1) {
|
171
|
-
is StatusResponseError -> {
|
172
|
-
val response = JsonObject()
|
173
|
-
response.addProperty("status", "error")
|
174
|
-
response.addProperty("createdAt", result.v1.createdAt.toString())
|
175
|
-
response.addProperty("reason", result.v1.error.toString())
|
176
|
-
val gson = Gson()
|
177
|
-
promise.resolve(gson.toJson(response))
|
174
|
+
is PrepareDetailedResponseSuccess.NotRequired -> {
|
175
|
+
println("prepareDetailed NotRequired: ")
|
178
176
|
}
|
179
177
|
}
|
180
178
|
}
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
is StatusResponsePending -> {
|
185
|
-
val response = JsonObject()
|
186
|
-
response.addProperty("status", "pending")
|
187
|
-
response.addProperty("createdAt", result.v1.createdAt.toString())
|
188
|
-
response.addProperty("checkIn", result.v1.checkIn.toString())
|
189
|
-
val gson = Gson()
|
190
|
-
promise.resolve(gson.toJson(response))
|
191
|
-
}
|
192
|
-
}
|
179
|
+
is PrepareDetailedResponse.Error -> {
|
180
|
+
println("prepareDetailed error: ")
|
181
|
+
println(result.v1.error)
|
193
182
|
}
|
194
183
|
}
|
184
|
+
|
185
|
+
val gson = Gson()
|
186
|
+
val jsonResult = gson.toJson(result)
|
187
|
+
promise.resolve(jsonResult)
|
188
|
+
} catch (e: Exception) {
|
189
|
+
// In case of an error, reject the promise
|
190
|
+
promise.reject("ERROR", "Yttrium checkRoute Error:" + e.message, e)
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
@ReactMethod
|
196
|
+
override fun status(params: ReadableMap, promise: Promise){
|
197
|
+
System.out.println("checkStatus: Hello from YttriumModule address")
|
198
|
+
|
199
|
+
GlobalScope.launch(Dispatchers.Main) {
|
200
|
+
try {
|
201
|
+
var orchestrationId = params.getString("orchestrationId") as String
|
202
|
+
val result = client.status(orchestrationId)
|
203
|
+
println("checkRoute: status: ")
|
204
|
+
println(result)
|
205
|
+
|
206
|
+
val gson = Gson()
|
207
|
+
val jsonResult = gson.toJson(result)
|
208
|
+
promise.resolve(jsonResult)
|
195
209
|
} catch (e: Exception) {
|
196
210
|
// In case of an error, reject the promise
|
197
211
|
promise.reject("ERROR", "Yttrium checkStatus Error:" + e.message, e)
|
@@ -205,13 +219,14 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
205
219
|
|
206
220
|
GlobalScope.launch(Dispatchers.Main) {
|
207
221
|
try {
|
208
|
-
|
209
|
-
val projectId = params.getString("projectId") as String
|
210
222
|
val orchestrationId = params.getString("orchestrationId") as String
|
211
|
-
val client = ChainAbstractionClient(projectId)
|
212
223
|
|
213
|
-
val availableResult =
|
214
|
-
val uiFields =
|
224
|
+
val availableResult = prepareAvailableResultsMap[orchestrationId]
|
225
|
+
val uiFields = availableResult.let {
|
226
|
+
if (it != null) {
|
227
|
+
client.getUiFields(it, Currency.USD)
|
228
|
+
}
|
229
|
+
}
|
215
230
|
val gson = Gson()
|
216
231
|
val resultJson: JsonElement = gson.toJsonTree(uiFields)
|
217
232
|
promise.resolve(gson.toJson(resultJson))
|
@@ -228,13 +243,10 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
228
243
|
|
229
244
|
GlobalScope.launch(Dispatchers.Main) {
|
230
245
|
try {
|
231
|
-
|
232
|
-
val projectId = params.getString("projectId") as String
|
233
246
|
val tokenAddress = params.getString("tokenAddress") as String
|
234
247
|
val ownerAddress = params.getString("ownerAddress") as String
|
235
248
|
val chainId = params.getString("chainId") as String
|
236
|
-
val client =
|
237
|
-
val result = client.erc20TokenBalance(chainId, tokenAddress, ownerAddress)
|
249
|
+
val result = client.erc20TokenBalance(chainId = chainId, token = tokenAddress, owner = ownerAddress)
|
238
250
|
val gson = Gson()
|
239
251
|
val resultJson: JsonElement = gson.toJsonTree(result)
|
240
252
|
promise.resolve(gson.toJson(resultJson))
|
@@ -245,27 +257,44 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
245
257
|
}
|
246
258
|
}
|
247
259
|
|
260
|
+
private fun getListOfStrings(params: ReadableMap, key: String): List<String> {
|
261
|
+
val readableArray: ReadableArray? = params.getArray(key)
|
262
|
+
return readableArray?.toArrayList()?.map { it as String } ?: emptyList()
|
263
|
+
}
|
264
|
+
|
248
265
|
@ReactMethod
|
249
|
-
override fun
|
250
|
-
System.out.println("
|
266
|
+
override fun execute(params: ReadableMap, promise: Promise){
|
267
|
+
System.out.println("getERC20Balance: Hello from YttriumModule address")
|
251
268
|
|
252
269
|
GlobalScope.launch(Dispatchers.Main) {
|
253
270
|
try {
|
271
|
+
val orchestrationId = params.getString("orchestrationId") as String
|
272
|
+
val bridgeSignedTransactions = getListOfStrings(params, "bridgeSignedTransactions")
|
273
|
+
val initialSignedTransaction = params.getString("initialSignedTransaction") as String
|
274
|
+
|
275
|
+
|
276
|
+
val prepareDetailedResult = prepareDetailedAvailableResultsMap[orchestrationId]
|
277
|
+
|
278
|
+
val result =
|
279
|
+
prepareDetailedResult?.let {
|
280
|
+
client.execute(
|
281
|
+
uiFields = it,
|
282
|
+
routeTxnSigs = bridgeSignedTransactions,
|
283
|
+
initialTxnSig = initialSignedTransaction,
|
284
|
+
)
|
285
|
+
}
|
254
286
|
|
255
|
-
val projectId = params.getString("projectId") as String
|
256
|
-
val chainId = params.getString("chainId") as String
|
257
|
-
val client = ChainAbstractionClient(projectId)
|
258
|
-
val result = client.estimateFees(chainId)
|
259
287
|
val gson = Gson()
|
260
288
|
val resultJson: JsonElement = gson.toJsonTree(result)
|
261
289
|
promise.resolve(gson.toJson(resultJson))
|
262
290
|
} catch (e: Exception) {
|
263
291
|
// In case of an error, reject the promise
|
264
|
-
promise.reject("ERROR", "Yttrium
|
292
|
+
promise.reject("ERROR", "Yttrium getERC20Balance Error:" + e.message, e)
|
265
293
|
}
|
266
294
|
}
|
267
295
|
}
|
268
296
|
|
297
|
+
|
269
298
|
companion object {
|
270
299
|
const val NAME = "RNWalletConnectModule"
|
271
300
|
}
|
@@ -9,11 +9,13 @@ abstract class RNWalletConnectModuleSpec internal constructor(context: ReactAppl
|
|
9
9
|
ReactContextBaseJavaModule(context) {
|
10
10
|
|
11
11
|
abstract fun isAppInstalled(packageName: String?, promise: Promise);
|
12
|
+
abstract fun initialize(params: ReadableMap, promise: Promise);
|
12
13
|
abstract fun prepare(params: ReadableMap, promise: Promise);
|
14
|
+
abstract fun prepareDetailed(params: ReadableMap, promise: Promise);
|
13
15
|
abstract fun status(params: ReadableMap, promise: Promise);
|
14
16
|
abstract fun getBridgeDetails(params: ReadableMap, promise: Promise);
|
15
|
-
abstract fun estimateFees(params: ReadableMap, promise: Promise);
|
16
17
|
abstract fun getERC20Balance(params: ReadableMap, promise: Promise);
|
18
|
+
abstract fun execute(params: ReadableMap, promise: Promise);
|
17
19
|
|
18
20
|
protected abstract fun getTypedExportedConstants(): Map<String, String>
|
19
21
|
|
@@ -21,4 +23,5 @@ abstract class RNWalletConnectModuleSpec internal constructor(context: ReactAppl
|
|
21
23
|
val constants: Map<String, String> = getTypedExportedConstants()
|
22
24
|
return constants
|
23
25
|
}
|
26
|
+
|
24
27
|
}
|
package/ios/Yttrium.mm
CHANGED
@@ -2,29 +2,39 @@
|
|
2
2
|
|
3
3
|
@interface RCT_EXTERN_MODULE(Yttrium, NSObject)
|
4
4
|
|
5
|
-
//RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
|
6
|
-
// withResolver:(RCTPromiseResolveBlock)resolve
|
7
|
-
// withRejecter:(RCTPromiseRejectBlock)reject)
|
8
|
-
//
|
9
|
-
RCT_EXTERN_METHOD(status:(id)params
|
10
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
11
|
-
reject:(RCTPromiseRejectBlock)reject)
|
12
5
|
|
13
|
-
RCT_EXTERN_METHOD(
|
6
|
+
RCT_EXTERN_METHOD(initialize:(id)params
|
14
7
|
resolve:(RCTPromiseResolveBlock)resolve
|
15
8
|
reject:(RCTPromiseRejectBlock)reject)
|
16
9
|
|
17
|
-
RCT_EXTERN_METHOD(
|
10
|
+
RCT_EXTERN_METHOD(prepareDetailed:(id)params
|
18
11
|
resolve:(RCTPromiseResolveBlock)resolve
|
19
12
|
reject:(RCTPromiseRejectBlock)reject)
|
20
13
|
|
21
|
-
RCT_EXTERN_METHOD(
|
14
|
+
RCT_EXTERN_METHOD(execute:(id)params
|
22
15
|
resolve:(RCTPromiseResolveBlock)resolve
|
23
16
|
reject:(RCTPromiseRejectBlock)reject)
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
|
19
|
+
//RCT_EXTERN_METHOD(status:(id)params
|
20
|
+
// resolve:(RCTPromiseResolveBlock)resolve
|
21
|
+
// reject:(RCTPromiseRejectBlock)reject)
|
22
|
+
//
|
23
|
+
//RCT_EXTERN_METHOD(prepare:(id)params
|
24
|
+
// resolve:(RCTPromiseResolveBlock)resolve
|
25
|
+
// reject:(RCTPromiseRejectBlock)reject)
|
26
|
+
//
|
27
|
+
//RCT_EXTERN_METHOD(getBridgeDetails:(id)params
|
28
|
+
// resolve:(RCTPromiseResolveBlock)resolve
|
29
|
+
// reject:(RCTPromiseRejectBlock)reject)
|
30
|
+
//
|
31
|
+
//RCT_EXTERN_METHOD(getERC20Balance:(id)params
|
32
|
+
// resolve:(RCTPromiseResolveBlock)resolve
|
33
|
+
// reject:(RCTPromiseRejectBlock)reject)
|
34
|
+
//
|
35
|
+
//RCT_EXTERN_METHOD(estimateFees:(id)params
|
36
|
+
// resolve:(RCTPromiseResolveBlock)resolve
|
37
|
+
// reject:(RCTPromiseRejectBlock)reject)
|
28
38
|
|
29
39
|
|
30
40
|
+ (BOOL)requiresMainQueueSetup
|