Skip to content

Commit

Permalink
Clear all sessions when disconnecting wallet connect
Browse files Browse the repository at this point in the history
  • Loading branch information
joemarct committed Dec 14, 2024
1 parent 1f8e42e commit 412f317
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src-capacitor/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
applicationId "com.paytaca.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 101
versionCode 103
versionName "v0.21.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
Expand Down
4 changes: 2 additions & 2 deletions src-capacitor/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 191;
CURRENT_PROJECT_VERSION = 193;
DEVELOPMENT_TEAM = 89X576BZBF;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand All @@ -387,7 +387,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/AppRelease.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 191;
CURRENT_PROJECT_VERSION = 193;
DEVELOPMENT_TEAM = 89X576BZBF;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand Down
4 changes: 3 additions & 1 deletion src/components/walletconnect/SessionInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const peerMetadata = computed(() => {
if (props.sessionType === 'request') {
// props.session is a sessionRequest object
// and session is a property of the sessionRequest object
return structuredClone(props.session.session.peer.metadata)
if (props.session.session) {
return structuredClone(props.session.session.peer.metadata)
}
}
return {}
})
Expand Down
11 changes: 9 additions & 2 deletions src/components/walletconnect/WalletConnectV2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,15 @@ const disconnectSession = async (activeSession) => {
class: `br-15 pt-card text-caption ${getDarkModeClass(darkMode.value)}`
}).onOk(() => resolve()).onCancel(() => reject())
})
// NOTE: Remove all sessions for now, allowing multiple sessions was problematic
activeSessions.value && delete activeSessions.value[activeSession.topic]
activeSessions.value = {}
sessionTopicWalletAddressMapping.value[activeSession.topic] && delete sessionTopicWalletAddressMapping.value[activeSession.topic]
sessionTopicWalletAddressMapping.value = {}
await web3Wallet.value.disconnectSession({
topic: activeSession.topic,
reason: getSdkError('USER_DISCONNECTED')
Expand Down Expand Up @@ -567,6 +574,8 @@ const approveSessionProposal = async (sessionProposal) => {
// Choose the first address by default
let selectedAddress = walletAddresses.value?.[0]
console.log('PROPOSAL', sessionProposal)
if (walletAddresses.value?.length > 1) {
// let user select the address wallet has more than 1 address
processingSession.value[sessionProposal.pairingTopic] = 'Selecting Address'
Expand Down Expand Up @@ -723,7 +732,6 @@ const respondToGetAccountsRequest = async (sessionRequest) => {
}
const respondToSessionRequest = async (sessionRequest) => {
console.log('Session Request', sessionRequest)
try {
processingSession.value[sessionRequest.id] = 'Confirming'
const id = sessionRequest?.id
Expand All @@ -743,7 +751,6 @@ const respondToSessionRequest = async (sessionRequest) => {
switch(method) {
case 'bch_getAddresses':
break;
case 'bch_getAccounts':
await respondToGetAccountsRequest(sessionRequest)
break;
Expand Down

0 comments on commit 412f317

Please sign in to comment.