Skip to content

Commit

Permalink
Merge pull request #338 from WalletConnect/develop
Browse files Browse the repository at this point in the history
RC2
  • Loading branch information
Talhaali00 committed Aug 11, 2022
2 parents c570a78 + 45a21d1 commit 027a55c
Show file tree
Hide file tree
Showing 57 changed files with 1,023 additions and 1,174 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci_relay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#name: Relay Integration
#
#
## IMPORTANT. GHA only for demo purposes.
#on:
# push:
# branches:
# - feature/sign/instrumented_tests
# pull_request:
# branches:
# - feature/sign/instrumented_tests
#
#concurrency:
# # Support push/pr as event types with different behaviors each:
# # 1. push: queue up builds by branch
# # 2. pr: only allow one run per PR
# group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref_name }}
# # If there is already a workflow running for the same pull request, cancel it
# # For non-PR triggers queue up builds
# cancel-in-progress: ${{ github.event_name == 'pull_request' }}
#
#jobs:
# validate:
# runs-on: macos-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Setup Java JDK
# uses: actions/[email protected]
# with:
# distribution: 'zulu'
# java-version: '11'
# architecture: x86_64
# - name: Instrumentation tests
# env:
# TEST_RELAY_URL: wss://relay.walletconnect.com
# TEST_PROJECT_ID: 2ee94aca5d98e6c05c38bce02bee952a
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 32
# arch: x86_64
# target: google_apis
# script: ./gradlew :sign:connectedCheck
21 changes: 12 additions & 9 deletions .github/workflows/intake.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow moves issues to the Kotlin board
# This workflow moves issues to the board
# when they receive the "accepted" label
# When WalletConnect Org members create issues they
# are automatically "accepted".
Expand All @@ -8,8 +8,6 @@ name: intake
on:
issues:
types: [opened, labeled]
pull_request:
types: [opened, labeled]

jobs:
add-to-project:
Expand All @@ -28,15 +26,20 @@ jobs:
if: github.event.action == 'opened'
runs-on: ubuntu-latest
steps:
- name: Check if organization member
id: is_organization_member
if: github.event.action == 'opened'
uses: JamesSingleton/[email protected]
- name: Check Core Team membership
uses: tspascoal/get-user-teams-membership@v1
id: is-core-team
with:
organization: WalletConnect
username: ${{ github.event_name != 'pull_request' && github.event.issue.user.login || github.event.sender.login }}
token: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }}
team: "Core Team"
GITHUB_TOKEN: ${{ secrets.ASSIGN_TO_PROJECT_GITHUB_TOKEN }}
- name: Print result
env:
CREATOR: ${{ github.event_name != 'pull_request' && github.event.issue.user.login || github.event.sender.login }}
IS_TEAM_MEMBER: ${{ steps.is-core-team.outputs.isTeamMember }}
run: echo "$CREATOR (Core Team Member $IS_TEAM_MEMBER) created this issue/PR"
- name: Label issues
if: ${{ steps.is-core-team.outputs.isTeamMember == 'true' }}
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
with:
add-labels: "accepted"
Expand Down
4 changes: 4 additions & 0 deletions signSDK/dapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
<activity
android:name="com.walletconnect.dapp.ui.host.DappSampleActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait">

<nav-graph android:value="@navigation/nav_graph" />

<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ class DappSampleApplication : Application() {
// Sample of how to use a URI to initialize the WalletConnect SDK
val initString = Sign.Params.Init(
application = this,
relayServerUrl = "wss://$WALLET_CONNECT_PROD_RELAY_URL?projectId=${BuildConfig.PROJECT_ID}",
//TODO: register at https://walletconnect.com/register to get a project ID
relayServerUrl = "wss://$WALLET_CONNECT_PROD_RELAY_URL?projectId=${BuildConfig.PROJECT_ID}",
metadata = Sign.Model.AppMetaData(
name = "Kotlin Dapp",
description = "Dapp description",
url = "example.dapp",
icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media")
icons = listOf("https://gblobscdn.gitbook.com/spaces%2F-LJJeCjcLrr53DcT1Ml7%2Favatar.png?alt=media"),
redirect = "kotlin-dapp-wc:/request"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.lifecycle.viewModelScope
import com.walletconnect.dapp.domain.DappDelegate
import com.walletconnect.dapp.ui.SampleDappEvents
import com.walletconnect.dapp.ui.connect.chain_select.ChainSelectionUI
import com.walletconnect.sample_common.EthChains
import com.walletconnect.sample_common.Chains
import com.walletconnect.sample_common.tag
import com.walletconnect.sign.client.Sign
import com.walletconnect.sign.client.SignClient
Expand All @@ -19,7 +19,7 @@ class ConnectViewModel : ViewModel() {
private val _listOfChainUI: MutableList<ChainSelectionUI> = mutableListOf()
get() {
return if (field.isEmpty()) {
EthChains.values().mapTo(field) {
Chains.values().mapTo(field) {
ChainSelectionUI(it.chainName, it.chainNamespace, it.chainReference, it.icon, it.methods, it.events)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.walletconnect.dapp.ui.connect.chain_select
data class ChainSelectionUI(
val chainName: String,
val chainNamespace: String,
val chainReference: Int,
val chainReference: String,
val icon: Int,
val methods: List<String>,
val events: List<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ class DappSampleActivity : AppCompatActivity(R.layout.activity_dapp) {
super.onDestroy()
viewModel.disconnect()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch

class SelectedAccountViewModel : ViewModel() {
private val _uiState: MutableStateFlow<SelectedAccountUI> = MutableStateFlow(SelectedAccountUI.Initial)
private val _uiState: MutableStateFlow<SelectedAccountUI> =
MutableStateFlow(SelectedAccountUI.Initial)
val uiState: StateFlow<SelectedAccountUI> = _uiState.asStateFlow()

private val _event: MutableSharedFlow<SampleDappEvents> = MutableSharedFlow()
Expand All @@ -32,11 +33,13 @@ class SelectedAccountViewModel : ViewModel() {
is Sign.Model.SessionRequestResponse -> {
val request = when (walletEvent.result) {
is Sign.Model.JsonRpcResponse.JsonRpcResult -> {
val successResult = (walletEvent.result as Sign.Model.JsonRpcResponse.JsonRpcResult)
val successResult =
(walletEvent.result as Sign.Model.JsonRpcResponse.JsonRpcResult)
SampleDappEvents.RequestSuccess(successResult.result)
}
is Sign.Model.JsonRpcResponse.JsonRpcError -> {
val errorResult = (walletEvent.result as Sign.Model.JsonRpcResponse.JsonRpcError)
val errorResult =
(walletEvent.result as Sign.Model.JsonRpcResponse.JsonRpcError)
SampleDappEvents.RequestPeerError("Error Message: ${errorResult.message}\n Error Code: ${errorResult.code}")
}
}
Expand Down Expand Up @@ -71,19 +74,23 @@ class SelectedAccountViewModel : ViewModel() {

SignClient.request(requestParams) {
viewModelScope.launch {
_event.emit(SampleDappEvents.RequestError(it.throwable.localizedMessage ?: "Error trying to send request"))
_event.emit(
SampleDappEvents.RequestError(
it.throwable.localizedMessage ?: "Error trying to send request"
)
)
}
}

val sessionRequestDeepLinkUri = "wc:/${requestParams.sessionTopic})}/request".toUri()
sendSessionRequestDeepLink(sessionRequestDeepLinkUri)
SignClient.getSettledSessionByTopic(requestParams.sessionTopic)?.redirect?.toUri()
?.let { deepLinkUri -> sendSessionRequestDeepLink(deepLinkUri) }
}
}

fun fetchAccountDetails(selectedAccountInfo: String) {
val (chainNamespace, chainReference, account) = selectedAccountInfo.split(":")
val chainDetails = EthChains.values().first {
it.chainNamespace == chainNamespace && it.chainReference == chainReference.toInt()
val chainDetails = Chains.values().first {
it.chainNamespace == chainNamespace && it.chainReference == chainReference
}
val listOfMethods: List<String> = SignClient.getListOfSettledSessions().filter { session ->
session.topic == DappDelegate.selectedSessionTopic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SessionFragment : Fragment(R.layout.fragment_session) {
private val binding by viewBinding(FragmentSessionBinding::bind)
private val viewModel: SessionViewModel by viewModels()
private val sessionAccountAdapter by lazy {
SessionAdapter() { selectedAccount ->
SessionAdapter { selectedAccount ->
val selectedAccountKey = getString(R.string.selected_account)
findNavController().navigate(R.id.action_fragment_session_to_fragment_selected_account, bundleOf(selectedAccountKey to selectedAccount))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data class SessionUI(
val name: String,
val address: String,
val chainNamespace: String,
val chainReference: Int,
val chainReference: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.walletconnect.dapp.domain.DappDelegate
import com.walletconnect.dapp.ui.SampleDappEvents
import com.walletconnect.sample_common.EthChains
import com.walletconnect.sample_common.Chains
import com.walletconnect.sample_common.tag
import com.walletconnect.sign.client.Sign
import com.walletconnect.sign.client.SignClient
Expand Down Expand Up @@ -47,8 +47,8 @@ class SessionViewModel : ViewModel() {
settledSession.namespaces.values.flatMap { it.accounts }
}.map { caip10Account ->
val (chainNamespace, chainReference, account) = caip10Account.split(":")
val chain = EthChains.values().first { chain ->
chain.chainNamespace == chainNamespace && chain.chainReference == chainReference.toInt()
val chain = Chains.values().first { chain ->
chain.chainNamespace == chainNamespace && chain.chainReference == chainReference
}

SessionUI(chain.icon, chain.name, account, chain.chainNamespace, chain.chainReference)
Expand Down
5 changes: 5 additions & 0 deletions signSDK/dapp/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
android:id="@+id/action_global_fragment_chain_selection"
app:destination="@id/fragment_chain_selection" />


<deepLink
app:action="android.intent.action.VIEW"
app:uri="kotlin-dapp-wc:/request" />

</navigation>

<fragment
Expand Down
Loading

0 comments on commit 027a55c

Please sign in to comment.