You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The controller client will always be the "wallet" which is exposing blockchain accounts to a "Dapp" and therefore is also in charge of signing.
41
-
To initialize the WalletConnect client, create a ClientTypes.InitialParams object in the Android Application class. The InitialParams object will need at least the API key and the Application. The InitialParams object will then be passed to the WalletConnect.initialize function.
38
+
39
+
The controller client will always be the wallet which is exposing blockchain accounts to a Dapp and therefore is also in charge of signing.
40
+
To initialize the WalletConnect client, create a `ClientTypes.InitialParams` object in the Android Application class. The InitialParams object will need at least the application class, the ProjectID and the wallet's AppMetaData. The InitialParams object will then be passed to the `WalletConnectClient` initialize function. IntitalParams also allows for custom URLs by passing URL string into the `hostName` property.
To pair the wallet with the Dapp, call the WalletConnectClient.pair function which needs a ClientTypes.PairParams and WalletConnectClientListeners.Pairing.
81
+
To pair the wallet with the Dapp, call the WalletConnectClient.pair function which needs a `ClientTypes.PairParams` and `WalletConnectClientListeners.Pairing`.
51
82
ClientTypes.Params is where the Dapp Uri will be passed.
52
-
WalletConnectClientListeners.Pairing is the callback that will be asynchronously called once there a pairing has been made with the Dapp. A SessionProposal object is returned once a pairing is made.
83
+
WalletConnectClientListeners.Pairing is the callback that will be asynchronously called once there a pairing has been made with the Dapp.
53
84
54
85
### **Session Approval**
86
+
NOTE: addresses provided in `accounts` array should follow [CAPI10](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md) semantics.
55
87
```kotlin
56
88
val accounts:List<String> =/*list of accounts on chains*/
57
-
val proposerPublicKey:String=/*proposerPublicKey from the Session Proposal*/
58
-
val proposalTtl:Long=/*Ttl from the Session Proposal*/
59
-
val proposalTopic:String=/*Topic from the Session Proposal*/
60
-
val approveParams:ClientTypes.ApproveParams=ClientTypes.ApproveParams(accounts, proposerPublicKey, proposalTtl, proposalTopic)
61
-
62
-
WalletConnectClient.approve(approveParams)
89
+
val sessionProposal:WalletConnectClientData=/*Session Proposal object*/
90
+
val approveParams:ClientTypes.ApproveParams=ClientTypes.ApproveParams(sessionProposal, accounts)
91
+
val listener:WalletConnectClientListeners.SessionApprove {
To send an approval for the Session Proposal, pass the Session Proposal public key, ttl, and topic along with the list of accounts to the WalletConnectClient.approve function.
102
+
103
+
To send an approval, pass a Session Proposal object along with the list of accounts to the `WalletConnectClient.approve` function. Listener will asynchronously expose the settled session if the operation is successful.
65
104
66
105
### **Session Rejection**
67
106
```kotlin
68
107
val rejectionReason:String=/*The reason for rejecting the Session Proposal*/
69
108
val proposalTopic:String=/*Topic from the Session Proposal*/
70
109
val rejectParams:ClientTypes.RejectParams=ClientTypes.RejectParams(rejectionReason, proposalTopic)
110
+
val listener:WalletConnectClientListneners.SessionReject {
To send a rejection for the Session Proposal, pass a rejection reason and the Session Proposal topic to the `WalletConnectClient.reject` function. Listener will asynchronously expose a `RejectedSession` object that will mirror the data sent for rejection.
122
+
123
+
### **Session Disconnect**
124
+
```kotlin
125
+
val disconnectionReason:String=/*The reason for disconnecting the Settled Session*/
126
+
val sessionTopic:String=/*Topic from the Settled Session*/
127
+
val disconnectParams =ClientTypes.DisconnectParams(sessionTopic, disconnectionReason)
128
+
val listener =object:WalletConnectClientListeners.SessionDelete {
To disconnect from a settle session, pass a disconnection reason and the Settled Session topic to the `WalletConnectClient.disconnect` function. Listener will asynchronously expose a DeleteSession object that will mirror the data sent for rejection.
141
+
142
+
### **Respond Request**
143
+
```kotlin
144
+
val sessionRequestTopic:String=/*Topic of Settled Session*/
145
+
val jsonRpcResponse:WalletConnectClientData.JsonRpcResponse.JsonRpcResult=/*Settled Session Request ID along with request data*/
146
+
val result =ClientTypes.ResponseParams(sessionTopic = sessionRequestTopic, jsonRpcResponse = jsonRpcResponse)
147
+
val listener =object:WalletConnectClientListeners.SessionPayload {
148
+
overridefunonError(error:Throwable) {
149
+
// Error
150
+
}
151
+
}
152
+
153
+
WalletConnectClient.respond(result, listener)
154
+
```
155
+
To respond to JSON-RPC methods that were sent from Dapps for a settle session, submit a `ClientTypes.ResponseParams` with the settled session's topic and request ID along with the respond data to the `WalletConnectClient.respond` function. Any errors would exposed through the `WalletConnectClientListeners.SessionPayload` listener.
156
+
157
+
### **Reject Request**
158
+
```kotlin
159
+
val sessionRequestTopic:String=/*Topic of Settled Session*/
160
+
val jsonRpcResponseError:WalletConnectClientData.JsonRpcResponse.JsonRpcError=/*Settled Session Request ID along with error code and message*/
161
+
val result =ClientTypes.ResponseParams(sessionTopic = sessionRequestTopic, jsonRpcResponse = jsonRpcResponseError)
162
+
val listener =object:WalletConnectClientListeners.SessionPayload {
163
+
overridefunonError(error:Throwable) {
164
+
// Error
165
+
}
166
+
}
167
+
168
+
WalletConnectClient.respond(result, listener)
169
+
```
170
+
To reject a JSON-RPC method that was sent from a Dapps for a settle session, submit a `ClientTypes.ResponseParams` with the settled session's topic and request ID along with the rejection data to the `WalletConnectClient.respond` function. Any errors would exposed through the `WalletConnectClientListeners.SessionPayload` listener.
171
+
172
+
### **Session Update**
173
+
```kotlin
174
+
val sessionTopic:String=/*Topic of Settled Session*/
175
+
val sessionState:WalletConnectClientData.SessionState=/*object with list of accounts to update*/
176
+
val updateParams =ClientTypes.UpdateParams(sessionTopic = sessionTopic, sessionState = sessionState)
177
+
val listener =object:WalletConnectClientListeners.SessionUpdate {
To update a settled session, create a `ClientTypes.UpdateParams` object with the settled session's topic and accounts to update session with to `WalletConnectClient.update`. Listener will echo the accounts updated on the Dapp if action is successful.
190
+
191
+
### **Session Upgrade**
192
+
```kotlin
193
+
val sessionTopic:String=/*Topic of Settled Session*/
194
+
val permissions:WalletConnectClientData.SessionPermissions=/*list of blockchains and JSON-RPC methods to upgrade with*/
195
+
val upgradeParams =ClientTypes.UpgradeParams(sessionTopic = sessionTopic, permissions = permissions)
196
+
val listener =object:WalletConnectClientListeners.SessionUpgrade {
To send a rejection for the Session Proposal, pass a rejection reason and the Session Proposal public key to the WalletConnectClient.approve function.
208
+
To upgrade a settled session, create a `ClientTypes.UpgradeParams` object with the settled session's topic and blockchains and JSON-RPC methods to upgrade the session with to `WalletConnectClient.upgrade`. Listener will echo the blockchains and JSON-RPC methods upgraded on the Dapp if action is successful.
209
+
210
+
### **Session Ping**
211
+
```kotlin
212
+
val sessionTopic:String=/*Topic of Settled Session*/
213
+
val pingParams =ClientTypes.PingParams(sessionTopic)
214
+
val listener =object:WalletConnectClientListeners.SessionPing {
215
+
overridefunonSuccess(topic:String) {
216
+
// Topic being pinged
217
+
}
218
+
219
+
overridefunonError(error:Throwable) {
220
+
// Error
221
+
}
222
+
}
223
+
224
+
WalletConnectClient.ping(pingParams, listener)
225
+
```
226
+
To ping a Dapp with a settled session, call `WalletConnectClient.ping` with the `ClientTypes.PingParams` with a settle session's topic. If ping is successful, topic is echo'd in listener.
227
+
228
+
### **Get List of Settled Sessions**
229
+
```kotlin
230
+
WalletConnectClient.getListOfSettledSessions()
231
+
```
232
+
To get a list of the most current setteld sessions, call `WalletConnectClient.getListOfSettledSessions()` which will return a list of type `WalletConnectClientData.SettledSession`.
233
+
234
+
### **Get List of Pending Sessions**
235
+
```kotlin
236
+
WalletConnectClient.getListOfPendingSession()
237
+
```
238
+
To get a list of the most current pending sessions, call `WalletConnectClient.getListOfPendingSession()` which will return a list of type `WalletConnectClientData.SessionProposal`.
239
+
240
+
### **Shutdown SDK**
241
+
```kotlin
242
+
WalletConnectClient.shutdown()
243
+
```
244
+
To make sure that the internal coroutines are handled correctly when leaving the application, call `WalletConnectClient.shutdown()` before exiting from the application.
245
+
<br>
246
+
247
+
## API Keys
75
248
76
-
### **Contributing**
77
-
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
249
+
For api keys look at [API Keys](../../api/api-keys.md)
0 commit comments