@walletconnect/react-native-compat 2.18.1-canary-exp-2 → 2.18.1-canary-ca-1

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.
@@ -5,15 +5,25 @@ buildscript {
5
5
  repositories {
6
6
  google()
7
7
  mavenCentral()
8
+ maven { url 'https://jitpack.io' }
8
9
  }
9
10
 
10
11
  dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
12
+ classpath "com.android.tools.build:gradle:8.5.1"
12
13
  // noinspection DifferentKotlinGradleVersion
13
14
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
15
  }
15
16
  }
16
17
 
18
+ allprojects {
19
+ repositories {
20
+ google()
21
+ mavenCentral()
22
+ maven { url 'https://jitpack.io' }
23
+ }
24
+ }
25
+
26
+
17
27
  def isNewArchitectureEnabled() {
18
28
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
29
  }
@@ -109,6 +119,11 @@ dependencies {
109
119
  //noinspection GradleDynamicVersion
110
120
  implementation "com.facebook.react:react-native:+"
111
121
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
122
+ implementation 'net.java.dev.jna:jna:5.12.1@aar'
123
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0' // Latest stable version
124
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0' // For Dispatchers.Main
125
+ implementation 'com.google.code.gson:gson:2.9.0'
126
+ implementation("com.github.reown-com:yttrium:0.4.11")
112
127
  }
113
128
 
114
129
  if (isNewArchitectureEnabled()) {
@@ -4,6 +4,14 @@ import com.facebook.react.bridge.ReactApplicationContext
4
4
  import com.facebook.react.bridge.ReactMethod
5
5
  import com.facebook.react.bridge.Promise
6
6
  import android.content.pm.PackageManager
7
+ import uniffi.uniffi_yttrium.ChainAbstractionClient
8
+ import kotlinx.coroutines.*
9
+ import com.facebook.react.bridge.ReadableMap
10
+ import uniffi.uniffi_yttrium.*
11
+ import uniffi.yttrium.*
12
+ import com.google.gson.Gson
13
+ import com.google.gson.JsonObject
14
+ import com.google.gson.JsonElement
7
15
 
8
16
  class RNWalletConnectModuleModule internal constructor(context: ReactApplicationContext) :
9
17
  RNWalletConnectModuleSpec(context) {
@@ -49,6 +57,215 @@ class RNWalletConnectModuleModule internal constructor(context: ReactApplication
49
57
  }
50
58
  }
51
59
 
60
+
61
+
62
+ // ------------------------------ Yttrium Chain Abstraction ------------------------------
63
+
64
+ private var availableResponseMap: MutableMap<String, RouteResponseAvailable> = mutableMapOf()
65
+
66
+
67
+ @ReactMethod
68
+ override fun prepare(params: ReadableMap, promise: Promise){
69
+ System.out.println("checkRoute: Hello from YttriumModule")
70
+ GlobalScope.launch(Dispatchers.Main) {
71
+ try {
72
+ var projectId = params.getString("projectId") as String
73
+ val transactionMap = params.getMap("transaction")
74
+ var client = ChainAbstractionClient(projectId)
75
+
76
+ if (transactionMap != null) {
77
+ // Extract values from the nested transaction map
78
+ val chainId = transactionMap.getString("chainId") ?: ""
79
+ val txData = transactionMap.getString("data") ?: ""
80
+ val from = transactionMap.getString("from") ?: ""
81
+ val to = transactionMap.getString("to") ?: ""
82
+ val value = transactionMap.getString("value") ?: "0"
83
+ val tx = InitialTransaction(chainId, from, to, value, txData)
84
+ val result = client.prepare(tx)
85
+ System.out.println("checkRoute: result: ")
86
+ System.out.println(result)
87
+ when (result) {
88
+ is PrepareResponse.Success -> {
89
+ when (result.v1) {
90
+ is RouteResponseSuccess.Available -> {
91
+ val availableResult = (result.v1 as RouteResponseSuccess.Available).v1
92
+ availableResponseMap[availableResult.orchestrationId] = availableResult
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))
99
+ }
100
+ is RouteResponseSuccess.NotRequired -> {
101
+ val response = JsonObject()
102
+ response.addProperty("status", "not_required")
103
+ val gson = Gson()
104
+ promise.resolve(gson.toJson(response))
105
+ }
106
+ }
107
+ }
108
+ is PrepareResponse.Error -> {
109
+ System.out.println(result.v1.error.toString())
110
+ when (result.v1.error.toString()) {
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
+ }
133
+ }
134
+ }
135
+
136
+ }
137
+ // Resolve the promise with the result
138
+ } catch (e: Exception) {
139
+ // In case of an error, reject the promise
140
+ promise.reject("ERROR", "Yttrium checkRoute Error:" + e.message, e)
141
+ }
142
+ }
143
+ }
144
+
145
+ @ReactMethod
146
+ override fun status(params: ReadableMap, promise: Promise){
147
+ System.out.println("checkStatus: Hello from YttriumModule address")
148
+
149
+ GlobalScope.launch(Dispatchers.Main) {
150
+ try {
151
+
152
+ var projectId = params.getString("projectId") as String
153
+ var orchestrationId = params.getString("orchestrationId") as String
154
+ var client = ChainAbstractionClient(projectId)
155
+
156
+ when (val result = client.status(orchestrationId)) {
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
+ }
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))
178
+ }
179
+ }
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))
191
+ }
192
+ }
193
+ }
194
+ }
195
+ } catch (e: Exception) {
196
+ // In case of an error, reject the promise
197
+ promise.reject("ERROR", "Yttrium checkStatus Error:" + e.message, e)
198
+ }
199
+ }
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
+
52
269
  companion object {
53
270
  const val NAME = "RNWalletConnectModule"
54
271
  }
@@ -3,11 +3,18 @@ package com.walletconnect.reactnativemodule
3
3
  import com.facebook.react.bridge.ReactApplicationContext
4
4
  import com.facebook.react.bridge.ReactContextBaseJavaModule
5
5
  import com.facebook.react.bridge.Promise
6
+ import com.facebook.react.bridge.ReadableMap
6
7
 
7
8
  abstract class RNWalletConnectModuleSpec internal constructor(context: ReactApplicationContext) :
8
9
  ReactContextBaseJavaModule(context) {
9
10
 
10
11
  abstract fun isAppInstalled(packageName: String?, promise: Promise);
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
+
11
18
  protected abstract fun getTypedExportedConstants(): Map<String, String>
12
19
 
13
20
  override fun getConstants(): Map<String, String> {
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { NativeModules } from "react-native";
1
2
  import { getApplicationModule } from "./module";
2
3
 
3
4
  // Polyfill TextEncode / TextDecode
@@ -75,3 +76,9 @@ if (typeof global?.Application === "undefined") {
75
76
  console.error("react-native-compat: Application module is not available");
76
77
  }
77
78
  }
79
+
80
+ // iOS uses Yttrium, Android uses RNWalletConnectModule
81
+ global.yttrium = NativeModules.Yttrium || NativeModules.RNWalletConnectModule;
82
+
83
+ // eslint-disable-next-line no-console
84
+ console.log("RN yttrium", global.yttrium);
@@ -0,0 +1,2 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTViewManager.h>
package/ios/Yttrium.mm ADDED
@@ -0,0 +1,35 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @interface RCT_EXTERN_MODULE(Yttrium, NSObject)
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
+
13
+ RCT_EXTERN_METHOD(prepare:(id)params
14
+ resolve:(RCTPromiseResolveBlock)resolve
15
+ reject:(RCTPromiseRejectBlock)reject)
16
+
17
+ RCT_EXTERN_METHOD(getBridgeDetails:(id)params
18
+ resolve:(RCTPromiseResolveBlock)resolve
19
+ reject:(RCTPromiseRejectBlock)reject)
20
+
21
+ RCT_EXTERN_METHOD(getERC20Balance:(id)params
22
+ resolve:(RCTPromiseResolveBlock)resolve
23
+ reject:(RCTPromiseRejectBlock)reject)
24
+
25
+ RCT_EXTERN_METHOD(estimateFees:(id)params
26
+ resolve:(RCTPromiseResolveBlock)resolve
27
+ reject:(RCTPromiseRejectBlock)reject)
28
+
29
+
30
+ + (BOOL)requiresMainQueueSetup
31
+ {
32
+ return NO;
33
+ }
34
+
35
+ @end
@@ -0,0 +1,304 @@
1
+ import YttriumWrapper
2
+
3
+
4
+ @objc(Yttrium)
5
+ class Yttrium: NSObject {
6
+
7
+ @objc
8
+ func status(_ 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 convertRouteResponseAvailableToDictionary(_ routeResponse: RouteResponseAvailable) -> [String: Any] {
53
+ func transactionToDictionary(_ transaction: YttriumWrapper.Transaction) -> [String: Any] {
54
+ return [
55
+ "chainId": transaction.chainId,
56
+ "from": transaction.from,
57
+ "to": transaction.to,
58
+ "value": transaction.value,
59
+ "input": transaction.input,
60
+ "gasLimit": transaction.gasLimit,
61
+ "nonce": transaction.nonce
62
+ ]
63
+ }
64
+
65
+ func fundingMetadataToDictionary(_ metadata: YttriumWrapper.FundingMetadata) -> [String: Any] {
66
+ return [
67
+ "chainId": metadata.chainId,
68
+ "tokenContract": metadata.tokenContract,
69
+ "symbol": metadata.symbol,
70
+ "amount": metadata.amount,
71
+ "bridgingFee": metadata.bridgingFee,
72
+ "decimals": metadata.decimals
73
+ ]
74
+ }
75
+
76
+ func initialTransactionMetadataToDictionary(_ metadata: YttriumWrapper.InitialTransactionMetadata) -> [String: Any] {
77
+ return [
78
+ "transferTo": metadata.transferTo,
79
+ "amount": metadata.amount,
80
+ "tokenContract": metadata.tokenContract,
81
+ "symbol": metadata.symbol,
82
+ "decimals": metadata.decimals
83
+ ]
84
+ }
85
+
86
+ func metadataToDictionary(_ metadata: YttriumWrapper.Metadata) -> [String: Any] {
87
+ return [
88
+ "fundingFrom": metadata.fundingFrom.map { fundingMetadataToDictionary($0) },
89
+ "initialTransaction": initialTransactionMetadataToDictionary(metadata.initialTransaction),
90
+ "checkIn": metadata.checkIn
91
+ ]
92
+ }
93
+
94
+ return [
95
+ "orchestrationId": routeResponse.orchestrationId,
96
+ "initialTransaction": transactionToDictionary(routeResponse.initialTransaction),
97
+ "transactions": routeResponse.transactions.map { transactionToDictionary($0) },
98
+ "metadata": metadataToDictionary(routeResponse.metadata)
99
+ ]
100
+ }
101
+
102
+ private var availableResponseDictionary: [String: RouteResponseAvailable] = [:]
103
+
104
+ @objc
105
+ func prepare(_ params: Any, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
106
+ print("checkRoute called with", params)
107
+ let dict = params as? [String: Any]
108
+
109
+ if let transactionData = dict?["transaction"] as? [String: String],
110
+ let from = transactionData["from"] ?? "" as Optional,
111
+ let chainId = transactionData["chainId"] ?? "" as Optional,
112
+ let data = transactionData["data"] ?? "" as Optional,
113
+ let value = transactionData["value"] ?? "" as Optional,
114
+ let to = transactionData["to"] ?? "" as Optional,
115
+ let projectId = dict?["projectId"] as? String {
116
+
117
+ let client = ChainAbstractionClient.init(projectId: projectId)
118
+ print("created client, checking route...")
119
+ Task {
120
+ do {
121
+ let transaction = InitialTransaction.init(chainId: chainId, from: from, to: to, value: value, input: data)
122
+
123
+ let routeResponseSuccess = try await client.prepare(initialTransaction: transaction)
124
+ print("result", routeResponseSuccess)
125
+
126
+ switch routeResponseSuccess {
127
+ case let .success(routeResponse):
128
+ switch routeResponse {
129
+ case let .available(availableResponse):
130
+
131
+ availableResponseDictionary[availableResponse.orchestrationId] = availableResponse;
132
+ // 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)
133
+ //
134
+ // let routesDetails = convertRouteUiFieldsToDictionary(uiFields)
135
+ // print("available result", availableResponse)
136
+ // print("ui_fields_json", routesDetails)
137
+ let responseDict = convertRouteResponseAvailableToDictionary(availableResponse)
138
+ print("parsed result dictionary", responseDict)
139
+ resolve(["status": "available", "data": responseDict])
140
+ // "routesDetails": routesDetails
141
+
142
+ case .notRequired(_):
143
+ print("not required")
144
+ resolve(["status": "not_required"])
145
+ }
146
+ case let .error(routeResponse):
147
+ switch routeResponse.error {
148
+ case BridgingError.insufficientFunds:
149
+ let responseDict: [String: Any] = [
150
+ "status": "error",
151
+ "reason": "insufficientFunds"
152
+ ]
153
+ resolve(responseDict)
154
+ case BridgingError.insufficientGasFunds:
155
+ let responseDict: [String: Any] = [
156
+ "status": "error",
157
+ "reason": "insufficientGasFunds"
158
+ ]
159
+ resolve(responseDict)
160
+ case BridgingError.noRoutesAvailable:
161
+ let responseDict: [String: Any] = [
162
+ "status": "error",
163
+ "reason": "noRoutesAvailable"
164
+ ]
165
+ resolve(responseDict)
166
+ }
167
+ print(routeResponse)
168
+ print(routeResponse.error)
169
+ }
170
+ // resolve(result)
171
+ } catch {
172
+ print("Error occurred: \(error)")
173
+ print(error)
174
+ reject("yttrium err", "yttrium_err", error)
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ func convertUiFieldsToDictionary(_ uiFields: UiFields) -> [String: Any] {
181
+ func feeEstimatedTransactionToDictionary(_ transaction: YttriumWrapper.FeeEstimatedTransaction) -> [String: Any] {
182
+ return [
183
+ "chainId": transaction.chainId,
184
+ "from": transaction.from,
185
+ "to": transaction.to,
186
+ "value": transaction.value,
187
+ "input": transaction.input,
188
+ "gasLimit": transaction.gasLimit,
189
+ "nonce": transaction.nonce,
190
+ "maxFeePerGas": transaction.maxFeePerGas,
191
+ "maxPriorityFeePerGas": transaction.maxPriorityFeePerGas
192
+ ]
193
+ }
194
+
195
+ func amountToDictionary(_ amount: YttriumWrapper.Amount) -> [String: Any] {
196
+ return [
197
+ "symbol": amount.symbol,
198
+ "amount": amount.amount,
199
+ "unit": amount.unit,
200
+ "formatted": amount.formatted,
201
+ "formattedAlt": amount.formattedAlt
202
+ ]
203
+ }
204
+
205
+ func transactionFeeToDictionary(_ fee: YttriumWrapper.TransactionFee) -> [String: Any] {
206
+ return [
207
+ "fee": amountToDictionary(fee.fee),
208
+ "localFee": amountToDictionary(fee.localFee)
209
+ ]
210
+ }
211
+
212
+ func txnDetailsToDictionary(_ txnDetails: YttriumWrapper.TxnDetails) -> [String: Any] {
213
+ return [
214
+ "transaction": feeEstimatedTransactionToDictionary(txnDetails.transaction),
215
+ "fee": transactionFeeToDictionary(txnDetails.fee)
216
+ ]
217
+ }
218
+
219
+ return [
220
+ "route": uiFields.route.map { txnDetailsToDictionary($0) },
221
+ "localRouteTotal": amountToDictionary(uiFields.localRouteTotal),
222
+ "bridge": uiFields.bridge.map { transactionFeeToDictionary($0) },
223
+ "localBridgeTotal": amountToDictionary(uiFields.localBridgeTotal),
224
+ "initial": txnDetailsToDictionary(uiFields.initial),
225
+ "localTotal": amountToDictionary(uiFields.localTotal)
226
+ ]
227
+ }
228
+
229
+ @objc
230
+ func getBridgeDetails(_ params: Any, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
231
+ print("getBridgeDetails called with", params)
232
+ let dict = params as? [String: String]
233
+
234
+ if let orchestrationId = dict?["orchestrationId"] ?? "" as Optional,
235
+ let projectId = dict?["projectId"] as? String {
236
+
237
+ let client = ChainAbstractionClient.init(projectId: projectId)
238
+ print("created client, getting UI fields...")
239
+ Task {
240
+ do {
241
+
242
+ let availableResponse = availableResponseDictionary[orchestrationId]!
243
+ let uiFields = try await client.getUiFields(routeResponse: availableResponse, currency: Currency.usd)
244
+ let uiFIeldsDict = convertUiFieldsToDictionary(uiFields)
245
+ print("getBridgeDetails result", uiFields)
246
+ resolve(uiFIeldsDict)
247
+ } catch {
248
+ print("Error occurred: \(error)")
249
+ print(error)
250
+ reject("yttrium err", "yttrium_err getBridgeDetails", error)
251
+ }
252
+ }
253
+ }
254
+ }
255
+
256
+ @objc
257
+ func getERC20Balance(_ params: Any, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
258
+ print("getERC20Balance called with", params)
259
+ let dict = params as? [String: String]
260
+
261
+ if let tokenAddress = dict?["tokenAddress"] ?? "" as Optional,
262
+ let ownerAddress = dict?["ownerAddress"] ?? "" as Optional,
263
+ let chainId = dict?["chainId"] ?? "" as Optional,
264
+ let projectId = dict?["projectId"] as? String {
265
+
266
+ let client = ChainAbstractionClient.init(projectId: projectId)
267
+ Task {
268
+ do {
269
+ let balance = try await client.erc20TokenBalance(chainId: chainId, token: tokenAddress, owner: ownerAddress)
270
+ print("getERC20Balance result", balance)
271
+ resolve(balance)
272
+ } catch {
273
+ print("Error occurred: \(error)")
274
+ print(error)
275
+ reject("yttrium err", "yttrium_err getERC20Balance", error)
276
+ }
277
+ }
278
+ }
279
+ }
280
+
281
+ @objc
282
+ func estimateFees(_ params: Any, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
283
+ print("getERC20Balance called with", params)
284
+ let dict = params as? [String: String]
285
+
286
+ if let chainId = dict?["chainId"] ?? "" as Optional,
287
+ let projectId = dict?["projectId"] as? String {
288
+
289
+ let client = ChainAbstractionClient.init(projectId: projectId)
290
+ Task {
291
+ do {
292
+ let fees = try await client.estimateFees(chainId: chainId)
293
+ print("estimateFees result", fees)
294
+ resolve(["maxFeePerGas": fees.maxFeePerGas, "maxPriorityFeePerGas": fees.maxPriorityFeePerGas])
295
+ } catch {
296
+ print("Error occurred: \(error)")
297
+ print(error)
298
+ reject("yttrium err", "yttrium_err estimateFees", error)
299
+ }
300
+ }
301
+ }
302
+ }
303
+
304
+ }
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.18.1-canary-exp-2",
4
+ "version": "2.18.1-canary-ca-1",
5
5
  "author": "WalletConnect, Inc. <walletconnect.com>",
6
6
  "homepage": "https://github.com/walletconnect/walletconnect-monorepo/",
7
7
  "license": "Apache-2.0",
@@ -14,7 +14,8 @@ Pod::Spec.new do |s|
14
14
  s.platforms = { :ios => "11.0", :visionos => "1.0" }
15
15
  s.source = { :git => "https://github.com/walletconnect/walletconnect-monorepo.git", :tag => "#{s.version}" }
16
16
 
17
- s.source_files = "ios/**/*.{h,m,mm}"
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+ s.dependency 'YttriumWrapper' , '0.8.35'
18
19
 
19
20
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
21
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.