@walletconnect/react-native-compat 2.17.2-canary-ca-4 → 2.17.2-canary-ca-6
Sign up to get free protection for your applications and to get access to all the features.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/walletconnect/reactnativemodule/RNWalletConnectModuleModule.kt +114 -47
- package/android/src/oldarch/RNWalletConnectModuleSpec.kt +6 -2
- package/ios/Yttrium.swift +200 -137
- package/package.json +1 -1
- package/react-native-compat.podspec +1 -1
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.4.11")
|
127
127
|
}
|
128
128
|
|
129
129
|
if (isNewArchitectureEnabled()) {
|
package/android/src/main/java/com/walletconnect/reactnativemodule/RNWalletConnectModuleModule.kt
CHANGED
@@ -7,7 +7,6 @@ import android.content.pm.PackageManager
|
|
7
7
|
import uniffi.uniffi_yttrium.ChainAbstractionClient
|
8
8
|
import kotlinx.coroutines.*
|
9
9
|
import com.facebook.react.bridge.ReadableMap
|
10
|
-
import uniffi.uniffi_yttrium.InitTransaction
|
11
10
|
import uniffi.uniffi_yttrium.*
|
12
11
|
import uniffi.yttrium.*
|
13
12
|
import com.google.gson.Gson
|
@@ -62,42 +61,40 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
62
61
|
|
63
62
|
// ------------------------------ Yttrium Chain Abstraction ------------------------------
|
64
63
|
|
64
|
+
private var availableResponseMap: MutableMap<String, RouteResponseAvailable> = mutableMapOf()
|
65
|
+
|
66
|
+
|
65
67
|
@ReactMethod
|
66
|
-
override fun
|
68
|
+
override fun prepare(params: ReadableMap, promise: Promise){
|
67
69
|
System.out.println("checkRoute: Hello from YttriumModule")
|
68
|
-
|
69
70
|
GlobalScope.launch(Dispatchers.Main) {
|
70
71
|
try {
|
71
72
|
var projectId = params.getString("projectId") as String
|
72
73
|
val transactionMap = params.getMap("transaction")
|
73
74
|
var client = ChainAbstractionClient(projectId)
|
74
|
-
|
75
|
+
|
75
76
|
if (transactionMap != null) {
|
76
77
|
// Extract values from the nested transaction map
|
77
78
|
val chainId = transactionMap.getString("chainId") ?: ""
|
78
79
|
val txData = transactionMap.getString("data") ?: ""
|
79
80
|
val from = transactionMap.getString("from") ?: ""
|
80
|
-
val gas = transactionMap.getString("gas") ?: "0"
|
81
|
-
val gasPrice = transactionMap.getString("gasPrice") ?: "0"
|
82
|
-
val maxFeePerGas = transactionMap.getString("maxFeePerGas") ?: "0"
|
83
|
-
val maxPriorityFeePerGas = transactionMap.getString("maxPriorityFeePerGas") ?: "0"
|
84
|
-
val nonce = transactionMap.getString("nonce") ?: "0"
|
85
81
|
val to = transactionMap.getString("to") ?: ""
|
86
82
|
val value = transactionMap.getString("value") ?: "0"
|
87
|
-
|
88
|
-
val
|
89
|
-
val result = client.route(tx)
|
83
|
+
val tx = InitialTransaction(chainId, from, to, value, txData)
|
84
|
+
val result = client.prepare(tx)
|
90
85
|
System.out.println("checkRoute: result: ")
|
91
86
|
System.out.println(result)
|
92
87
|
when (result) {
|
93
|
-
is
|
88
|
+
is PrepareResponse.Success -> {
|
94
89
|
when (result.v1) {
|
95
90
|
is RouteResponseSuccess.Available -> {
|
91
|
+
val availableResult = (result.v1 as RouteResponseSuccess.Available).v1
|
92
|
+
availableResponseMap[availableResult.orchestrationId] = availableResult
|
96
93
|
val gson = Gson()
|
97
|
-
val
|
94
|
+
val routesJson: JsonElement = gson.toJsonTree(availableResult)
|
98
95
|
val response = JsonObject()
|
99
96
|
response.addProperty("status", "available")
|
100
|
-
response.add("data",
|
97
|
+
response.add("data", routesJson)
|
101
98
|
promise.resolve(gson.toJson(response))
|
102
99
|
}
|
103
100
|
is RouteResponseSuccess.NotRequired -> {
|
@@ -108,7 +105,7 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
108
105
|
}
|
109
106
|
}
|
110
107
|
}
|
111
|
-
is
|
108
|
+
is PrepareResponse.Error -> {
|
112
109
|
System.out.println(result.v1.error.toString())
|
113
110
|
when (result.v1.error.toString()) {
|
114
111
|
"NO_ROUTES_AVAILABLE" -> {
|
@@ -146,7 +143,7 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
146
143
|
}
|
147
144
|
|
148
145
|
@ReactMethod
|
149
|
-
override fun
|
146
|
+
override fun status(params: ReadableMap, promise: Promise){
|
150
147
|
System.out.println("checkStatus: Hello from YttriumModule address")
|
151
148
|
|
152
149
|
GlobalScope.launch(Dispatchers.Main) {
|
@@ -157,48 +154,118 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
|
|
157
154
|
var client = ChainAbstractionClient(projectId)
|
158
155
|
|
159
156
|
when (val result = client.status(orchestrationId)) {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
}
|
157
|
+
is StatusResponse.Completed -> {
|
158
|
+
when (result.v1) {
|
159
|
+
is StatusResponseCompleted -> {
|
160
|
+
val response = JsonObject()
|
161
|
+
response.addProperty("status", "completed")
|
162
|
+
response.addProperty("createdAt", result.v1.createdAt.toString())
|
163
|
+
val gson = Gson()
|
164
|
+
promise.resolve(gson.toJson(response))
|
165
|
+
}
|
170
166
|
}
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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))
|
181
178
|
}
|
182
179
|
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
180
|
+
}
|
181
|
+
|
182
|
+
is StatusResponse.Pending -> {
|
183
|
+
when (result.v1) {
|
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))
|
193
191
|
}
|
194
192
|
}
|
195
193
|
}
|
194
|
+
}
|
196
195
|
} catch (e: Exception) {
|
197
196
|
// In case of an error, reject the promise
|
198
197
|
promise.reject("ERROR", "Yttrium checkStatus Error:" + e.message, e)
|
199
198
|
}
|
200
199
|
}
|
201
200
|
}
|
201
|
+
|
202
|
+
@ReactMethod
|
203
|
+
override fun getBridgeDetails(params: ReadableMap, promise: Promise){
|
204
|
+
System.out.println("getFulfilmentDetails: Hello from YttriumModule address")
|
205
|
+
|
206
|
+
GlobalScope.launch(Dispatchers.Main) {
|
207
|
+
try {
|
208
|
+
|
209
|
+
val projectId = params.getString("projectId") as String
|
210
|
+
val orchestrationId = params.getString("orchestrationId") as String
|
211
|
+
val client = ChainAbstractionClient(projectId)
|
212
|
+
|
213
|
+
val availableResult = availableResponseMap[orchestrationId] as RouteResponseAvailable
|
214
|
+
val uiFields = client.getUiFields(availableResult, Currency.USD)
|
215
|
+
val gson = Gson()
|
216
|
+
val resultJson: JsonElement = gson.toJsonTree(uiFields)
|
217
|
+
promise.resolve(gson.toJson(resultJson))
|
218
|
+
} catch (e: Exception) {
|
219
|
+
// In case of an error, reject the promise
|
220
|
+
promise.reject("ERROR", "Yttrium getFulfilmentDetails Error:" + e.message, e)
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
@ReactMethod
|
226
|
+
override fun getERC20Balance(params: ReadableMap, promise: Promise){
|
227
|
+
System.out.println("getERC20Balance: Hello from YttriumModule address")
|
228
|
+
|
229
|
+
GlobalScope.launch(Dispatchers.Main) {
|
230
|
+
try {
|
231
|
+
|
232
|
+
val projectId = params.getString("projectId") as String
|
233
|
+
val tokenAddress = params.getString("tokenAddress") as String
|
234
|
+
val ownerAddress = params.getString("ownerAddress") as String
|
235
|
+
val chainId = params.getString("chainId") as String
|
236
|
+
val client = ChainAbstractionClient(projectId)
|
237
|
+
val result = client.erc20TokenBalance(chainId, tokenAddress, ownerAddress)
|
238
|
+
val gson = Gson()
|
239
|
+
val resultJson: JsonElement = gson.toJsonTree(result)
|
240
|
+
promise.resolve(gson.toJson(resultJson))
|
241
|
+
} catch (e: Exception) {
|
242
|
+
// In case of an error, reject the promise
|
243
|
+
promise.reject("ERROR", "Yttrium getERC20Balance Error:" + e.message, e)
|
244
|
+
}
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
@ReactMethod
|
249
|
+
override fun estimateFees(params: ReadableMap, promise: Promise){
|
250
|
+
System.out.println("estimateFees: Hello from YttriumModule address")
|
251
|
+
|
252
|
+
GlobalScope.launch(Dispatchers.Main) {
|
253
|
+
try {
|
254
|
+
|
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
|
+
val gson = Gson()
|
260
|
+
val resultJson: JsonElement = gson.toJsonTree(result)
|
261
|
+
promise.resolve(gson.toJson(resultJson))
|
262
|
+
} catch (e: Exception) {
|
263
|
+
// In case of an error, reject the promise
|
264
|
+
promise.reject("ERROR", "Yttrium estimateFees Error:" + e.message, e)
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
202
269
|
companion object {
|
203
270
|
const val NAME = "RNWalletConnectModule"
|
204
271
|
}
|
@@ -9,8 +9,12 @@ 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
|
13
|
-
abstract fun
|
12
|
+
abstract fun prepare(params: ReadableMap, promise: Promise);
|
13
|
+
abstract fun status(params: ReadableMap, promise: Promise);
|
14
|
+
abstract fun getBridgeDetails(params: ReadableMap, promise: Promise);
|
15
|
+
abstract fun estimateFees(params: ReadableMap, promise: Promise);
|
16
|
+
abstract fun getERC20Balance(params: ReadableMap, promise: Promise);
|
17
|
+
|
14
18
|
protected abstract fun getTypedExportedConstants(): Map<String, String>
|
15
19
|
|
16
20
|
override fun getConstants(): Map<String, String> {
|
package/ios/Yttrium.swift
CHANGED
@@ -3,152 +3,215 @@ import YttriumWrapper
|
|
3
3
|
|
4
4
|
@objc(Yttrium)
|
5
5
|
class Yttrium: NSObject {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
6
|
+
|
7
|
+
@objc
|
8
|
+
func checkStatus(_ params: Any, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
9
|
+
print("checkStatus called with", params )
|
10
|
+
if let dict = params as? [String: Any],
|
11
|
+
let projectId = dict["projectId"] as? String,
|
12
|
+
let orchestrationId = dict["orchestrationId"] as? String {
|
13
|
+
let client = ChainAbstractionClient.init(projectId: projectId)
|
14
|
+
Task {
|
15
|
+
do {
|
16
|
+
let statusResponse = try await client.status(orchestrationId: orchestrationId)
|
17
|
+
|
18
|
+
switch statusResponse {
|
19
|
+
case let .completed(statusResponseCompleted):
|
20
|
+
print("status response completed", statusResponseCompleted)
|
21
|
+
let responseDict: [String: Any] = [
|
22
|
+
"createdAt": statusResponseCompleted.createdAt,
|
23
|
+
"status": "completed"
|
24
|
+
]
|
25
|
+
resolve(responseDict)
|
26
|
+
case let .error(statusResponseError):
|
27
|
+
print("status response error", statusResponseError)
|
28
|
+
let responseDict: [String: Any] = [
|
29
|
+
"createdAt": statusResponseError.createdAt,
|
30
|
+
"reason": statusResponseError.error,
|
31
|
+
"status": "error"
|
32
|
+
]
|
33
|
+
resolve(responseDict)
|
34
|
+
case let .pending(statusResponsePending):
|
35
|
+
print("status response pending", statusResponsePending)
|
36
|
+
let responseDict: [String: Any] = [
|
37
|
+
"createdAt": statusResponsePending.createdAt,
|
38
|
+
"checkIn": statusResponsePending.checkIn,
|
39
|
+
"status": "pending"
|
40
|
+
]
|
41
|
+
resolve(responseDict)
|
42
|
+
}
|
43
|
+
} catch {
|
44
|
+
print("Error occurred: \(error)")
|
45
|
+
print(error)
|
46
|
+
reject("checkStatus err", "checkStatus", error)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
func availableResponseToDictionary(_ response: YttriumWrapper.RouteResponseAvailable) -> [String: Any] {
|
53
|
+
return [
|
54
|
+
"orchestrationId": response.orchestrationId,
|
55
|
+
"transactions": response.transactions.map { transaction in
|
56
|
+
return [
|
57
|
+
"from": transaction.from,
|
58
|
+
"to": transaction.to,
|
59
|
+
"value": transaction.value,
|
60
|
+
"gas": transaction.gas,
|
61
|
+
"data": transaction.data,
|
62
|
+
"nonce": transaction.nonce,
|
63
|
+
"chainId": transaction.chainId,
|
64
|
+
"gasPrice": transaction.gasPrice,
|
65
|
+
"maxFeePerGas": transaction.maxFeePerGas,
|
66
|
+
"maxPriorityFeePerGas": transaction.maxPriorityFeePerGas,
|
67
|
+
]
|
68
|
+
},
|
69
|
+
"metadata": [
|
70
|
+
"fundingFrom": response.metadata.fundingFrom.map { funding in
|
71
|
+
return [
|
72
|
+
"chainId": funding.chainId,
|
73
|
+
"tokenContract": funding.tokenContract,
|
74
|
+
"symbol": funding.symbol,
|
75
|
+
"amount": funding.amount,
|
76
|
+
]
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"checkIn": response.metadata.checkIn,
|
80
|
+
]
|
81
|
+
}
|
82
|
+
|
83
|
+
func convertRouteUiFieldsToDictionary(_ routeUiFields: RouteUiFields) -> [String: Any] {
|
84
|
+
func transactionToDictionary(transaction: YttriumWrapper.Transaction) -> [String: Any] {
|
85
|
+
return [
|
86
|
+
"from": transaction.from,
|
87
|
+
"to": transaction.to,
|
88
|
+
"value": transaction.value,
|
89
|
+
"gas": transaction.gas,
|
90
|
+
"data": transaction.data,
|
91
|
+
"nonce": transaction.nonce,
|
92
|
+
"chainId": transaction.chainId,
|
93
|
+
"gasPrice": transaction.gasPrice,
|
94
|
+
"maxFeePerGas": transaction.maxFeePerGas,
|
95
|
+
"maxPriorityFeePerGas": transaction.maxPriorityFeePerGas
|
24
96
|
]
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"status": "error"
|
97
|
+
}
|
98
|
+
|
99
|
+
func estimationToDictionary(estimation: YttriumWrapper.Eip1559Estimation) -> [String: Any] {
|
100
|
+
return [
|
101
|
+
"maxFeePerGas": estimation.maxFeePerGas,
|
102
|
+
"maxPriorityFeePerGas": estimation.maxPriorityFeePerGas
|
32
103
|
]
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
"status": "pending"
|
104
|
+
}
|
105
|
+
|
106
|
+
func feeToDictionary(fee: YttriumWrapper.TransactionFee) -> [String: Any] {
|
107
|
+
return [
|
108
|
+
"fee": amountToDictionary(amount: fee.fee),
|
109
|
+
"localFee": amountToDictionary(amount: fee.localFee)
|
40
110
|
]
|
41
|
-
resolve(responseDict)
|
42
|
-
}
|
43
|
-
} catch {
|
44
|
-
print("Error occurred: \(error)")
|
45
|
-
print(error)
|
46
|
-
reject("checkStatus err", "checkStatus", error)
|
47
111
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
112
|
+
|
113
|
+
func amountToDictionary(amount: YttriumWrapper.Amount) -> [String: Any] {
|
114
|
+
return [
|
115
|
+
"symbol": amount.symbol,
|
116
|
+
"amount": amount.amount,
|
117
|
+
"unit": amount.unit,
|
118
|
+
"formatted": amount.formatted,
|
119
|
+
"formattedAlt": amount.formattedAlt
|
120
|
+
]
|
121
|
+
}
|
122
|
+
|
123
|
+
func txnDetailsToDictionary(details: YttriumWrapper.TxnDetails) -> [String: Any] {
|
124
|
+
return [
|
125
|
+
"transaction": transactionToDictionary(transaction: details.transaction),
|
126
|
+
"estimate": estimationToDictionary(estimation: details.estimate),
|
127
|
+
"fee": feeToDictionary(fee: details.fee)
|
128
|
+
]
|
129
|
+
}
|
130
|
+
|
56
131
|
return [
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
"data": transaction.data,
|
62
|
-
"nonce": transaction.nonce,
|
63
|
-
"chainId": transaction.chainId,
|
64
|
-
"gasPrice": transaction.gasPrice,
|
65
|
-
"maxFeePerGas": transaction.maxFeePerGas,
|
66
|
-
"maxPriorityFeePerGas": transaction.maxPriorityFeePerGas,
|
132
|
+
"route": routeUiFields.route.map { txnDetailsToDictionary(details: $0) },
|
133
|
+
"bridge": routeUiFields.bridge.map { feeToDictionary(fee: $0) },
|
134
|
+
"initial": txnDetailsToDictionary(details: routeUiFields.initial),
|
135
|
+
"localTotal": amountToDictionary(amount: routeUiFields.localTotal)
|
67
136
|
]
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if let dict = params as? [String: Any],
|
87
|
-
let transactionData = dict["transaction"] as? [String: Any],
|
88
|
-
let from = transactionData["from"] as? FfiAddress,
|
89
|
-
let chainId = transactionData["chainId"] as? String,
|
90
|
-
let data = transactionData["data"] as? FfiBytes,
|
91
|
-
let gasPrice = transactionData["gasPrice"] as? String,
|
92
|
-
let gas = transactionData["gas"] as? Ffiu64,
|
93
|
-
let value = transactionData["value"] as? Ffiu256,
|
94
|
-
let to = transactionData["to"] as? FfiAddress,
|
95
|
-
let maxFeePerGas = transactionData["maxFeePerGas"] as? Ffiu256,
|
96
|
-
let maxPriorityFeePerGas = transactionData["maxPriorityFeePerGas"] as? Ffiu256,
|
97
|
-
let nonce = transactionData["nonce"] as? Ffiu64,
|
98
|
-
let projectId = dict["projectId"] as? String {
|
99
|
-
|
100
|
-
|
101
|
-
let client = ChainAbstractionClient.init(projectId: projectId)
|
102
|
-
print("created client, checking route...")
|
103
|
-
Task {
|
104
|
-
do {
|
105
|
-
let transaction = InitTransaction.init(from: from, to: to, value: value, gas: gas, gasPrice: gasPrice, data: data, nonce: nonce, maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas, chainId: chainId)
|
137
|
+
}
|
138
|
+
|
139
|
+
@objc
|
140
|
+
func checkRoute(_ params: Any, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
141
|
+
print("checkRoute called with", params)
|
142
|
+
if let dict = params as? [String: Any],
|
143
|
+
let transactionData = dict["transaction"] as? [String: Any],
|
144
|
+
let from = transactionData["from"] as? FfiAddress,
|
145
|
+
let chainId = transactionData["chainId"] as? String,
|
146
|
+
let data = transactionData["data"] as? FfiBytes,
|
147
|
+
let gasPrice = transactionData["gasPrice"] as? String,
|
148
|
+
let gas = transactionData["gas"] as? Ffiu64,
|
149
|
+
let value = transactionData["value"] as? Ffiu256,
|
150
|
+
let to = transactionData["to"] as? FfiAddress,
|
151
|
+
let maxFeePerGas = transactionData["maxFeePerGas"] as? Ffiu256,
|
152
|
+
let maxPriorityFeePerGas = transactionData["maxPriorityFeePerGas"] as? Ffiu256,
|
153
|
+
let nonce = transactionData["nonce"] as? Ffiu64,
|
154
|
+
let projectId = dict["projectId"] as? String {
|
106
155
|
|
107
|
-
let routeResponseSuccess = try await client.route(transaction: transaction)
|
108
|
-
print("result", routeResponseSuccess)
|
109
156
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
157
|
+
let client = ChainAbstractionClient.init(projectId: projectId)
|
158
|
+
print("created client, checking route...")
|
159
|
+
Task {
|
160
|
+
do {
|
161
|
+
let transaction = InitTransaction.init(from: from, to: to, value: value, gas: gas, gasPrice: gasPrice, data: data, nonce: nonce, maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas, chainId: chainId)
|
162
|
+
|
163
|
+
let routeResponseSuccess = try await client.route(transaction: transaction)
|
164
|
+
print("result", routeResponseSuccess)
|
165
|
+
|
166
|
+
switch routeResponseSuccess {
|
167
|
+
case let .success(routeResponse):
|
168
|
+
switch routeResponse {
|
169
|
+
case let .available(availableResponse):
|
170
|
+
let uiFields = try await client.getRouteUiFields(routeResponse: availableResponse, initialTransaction: Transaction(from: from, to: to, value: value, gas: gas, data: data, nonce: nonce, chainId: chainId, gasPrice: gasPrice, maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas), currency: Currency.usd)
|
171
|
+
|
172
|
+
let routesDetails = convertRouteUiFieldsToDictionary(uiFields)
|
173
|
+
|
174
|
+
print("ui_fields_json", routesDetails)
|
175
|
+
let responseDict = availableResponseToDictionary(availableResponse)
|
176
|
+
resolve(["status": "available", "data": [
|
177
|
+
"routes": responseDict,
|
178
|
+
"routesDetails": routesDetails
|
179
|
+
]])
|
180
|
+
case .notRequired(_):
|
181
|
+
print("not required")
|
182
|
+
resolve(["status": "not_required"])
|
183
|
+
}
|
184
|
+
case let .error(routeResponse):
|
185
|
+
switch routeResponse.error {
|
186
|
+
case BridgingError.insufficientFunds:
|
187
|
+
let responseDict: [String: Any] = [
|
188
|
+
"status": "error",
|
189
|
+
"reason": "insufficientFunds"
|
190
|
+
]
|
191
|
+
resolve(responseDict)
|
192
|
+
case BridgingError.insufficientGasFunds:
|
193
|
+
let responseDict: [String: Any] = [
|
194
|
+
"status": "error",
|
195
|
+
"reason": "insufficientGasFunds"
|
196
|
+
]
|
197
|
+
resolve(responseDict)
|
198
|
+
case BridgingError.noRoutesAvailable:
|
199
|
+
let responseDict: [String: Any] = [
|
200
|
+
"status": "error",
|
201
|
+
"reason": "noRoutesAvailable"
|
202
|
+
]
|
203
|
+
resolve(responseDict)
|
204
|
+
}
|
205
|
+
print(routeResponse)
|
206
|
+
print(routeResponse.error)
|
207
|
+
}
|
208
|
+
// resolve(result)
|
209
|
+
} catch {
|
210
|
+
print("Error occurred: \(error)")
|
211
|
+
print(error)
|
212
|
+
reject("yttrium err", "yttrium_err", error)
|
213
|
+
}
|
143
214
|
}
|
144
|
-
// resolve(result)
|
145
|
-
} catch {
|
146
|
-
print("Error occurred: \(error)")
|
147
|
-
print(error)
|
148
|
-
reject("yttrium err", "yttrium_err", error)
|
149
|
-
}
|
150
215
|
}
|
151
216
|
}
|
152
|
-
|
153
|
-
}
|
154
217
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@walletconnect/react-native-compat",
|
3
3
|
"description": "Shims for WalletConnect Protocol in React Native Projects",
|
4
|
-
"version": "2.17.2-canary-ca-
|
4
|
+
"version": "2.17.2-canary-ca-6",
|
5
5
|
"author": "WalletConnect, Inc. <walletconnect.com>",
|
6
6
|
"homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
|
7
7
|
"license": "Apache-2.0",
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
15
15
|
s.source = { :git => "https://github.com/walletconnect/walletconnect-monorepo.git", :tag => "#{s.version}" }
|
16
16
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
18
|
-
s.dependency 'YttriumWrapper' , '0.
|
18
|
+
s.dependency 'YttriumWrapper' , '0.4.6'
|
19
19
|
|
20
20
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
21
21
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|