Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(walletconnect): walletconnect integration #2223

Open
wants to merge 132 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
9100780
init, start walletconnect client impl
borngraced Sep 9, 2024
ca3f558
save dev state - walletconnect client impl
borngraced Sep 9, 2024
c3dc6c6
save dev state - WalletConnect client impl
borngraced Sep 9, 2024
0eea639
rough implementations
borngraced Sep 11, 2024
588316f
commit lock file
borngraced Sep 11, 2024
60a2fc5
save dev state - handle connection close, session improvements, etc
borngraced Sep 12, 2024
fd8797c
minor changes
borngraced Sep 12, 2024
437767b
fix wasm compilation
borngraced Sep 13, 2024
6374da3
minor changes - create metadata mod
borngraced Sep 13, 2024
1c9cfe0
minor changes and code organization
borngraced Sep 14, 2024
f7987dd
minor changes + merge session and session_key mod
borngraced Sep 14, 2024
1f2adb2
minor changes to namespaces
borngraced Sep 15, 2024
658357f
some improvements
borngraced Sep 16, 2024
98026ac
add some session fn doc comments
borngraced Sep 16, 2024
9dddb91
big improvements to session handling
borngraced Sep 16, 2024
52a0f72
implement session delete and cleaup
borngraced Sep 17, 2024
9f5944c
improve code and locking
borngraced Sep 17, 2024
dff1b42
remove unused dep
borngraced Sep 17, 2024
591fbdb
refactorings and cleanupds
borngraced Sep 17, 2024
f6e7864
minor changes
borngraced Sep 18, 2024
f535f0b
make session single
borngraced Sep 19, 2024
3eb8969
minor changes
borngraced Sep 19, 2024
2d68488
save dev state
borngraced Sep 19, 2024
42dd5ba
implement coin activation for tendermint and other minor changes
borngraced Sep 21, 2024
edcb5a7
improve code and minor needed changes
borngraced Sep 22, 2024
e606ca4
improve relayer disconnection, remove unneeded changes, track topic s…
borngraced Sep 23, 2024
d7b5a17
fix tendermint pubkey derivation from walletconnect
borngraced Sep 23, 2024
3a85a17
start persistent session storage implementation
borngraced Sep 23, 2024
be98c40
implement sqlite session storage table and insert session method
borngraced Sep 24, 2024
6453a33
fix cyclic deps and continue storage implementations
borngraced Sep 25, 2024
9f87a9e
implement WASM persistent storage
borngraced Sep 26, 2024
6135665
implement persistent indexed_db session storage
borngraced Sep 26, 2024
5457d80
save dev state - implement wc rpc commands
borngraced Sep 26, 2024
9d12079
move walletconnect rpc to mm2_main rpc
borngraced Sep 26, 2024
03d9978
remove mm2_test_helpers lock file
borngraced Sep 26, 2024
32e46d9
format mm2_net cargo.toml
borngraced Sep 26, 2024
1e352b1
update storage session upon session settle response/request
borngraced Sep 26, 2024
a30511b
add tokio to wc dependency list
borngraced Sep 26, 2024
341b18e
improve tenderming with_pubkey activation params
borngraced Sep 26, 2024
4c8e299
minor changes
borngraced Sep 29, 2024
73d8315
fix proposer mod
borngraced Sep 29, 2024
c1accc9
merge with dev
borngraced Sep 29, 2024
7ab33d5
implement walletconnect sign tx for tendermint - wip
borngraced Oct 2, 2024
0bcd41c
remove chain params from get cosmos account method
borngraced Oct 2, 2024
b2ec309
tx impl - wip
borngraced Oct 2, 2024
2e25bde
save dev state
borngraced Oct 6, 2024
328bc76
handle client connnection/reconnection efficiently and minor renaming
borngraced Oct 6, 2024
9b20d7f
minor changes
borngraced Oct 6, 2024
ca2e19c
implement multi session management
borngraced Oct 8, 2024
481f1c3
remove mm2_test_helpers lock file
borngraced Oct 8, 2024
0c00710
refactoring and unit tests
borngraced Oct 8, 2024
e5e2150
fix session topic generation bug
borngraced Oct 8, 2024
8d749de
tendermint sign tx impl fixes
borngraced Oct 9, 2024
8b1b6c3
improve wc tx_signing codes
borngraced Oct 9, 2024
4202950
minor fix
borngraced Oct 9, 2024
d440ed9
add more session rpc endpoint
borngraced Oct 10, 2024
f3cf28b
update wc deps
borngraced Oct 10, 2024
e56f8d7
update wc_common deps
borngraced Oct 10, 2024
1ab21d7
merge with dev and fix conflicts
borngraced Oct 10, 2024
a498381
use rustls
borngraced Oct 10, 2024
c7b41a8
update bip39 deps
borngraced Oct 11, 2024
8fc7620
fix wasm clippy
borngraced Oct 11, 2024
2d52404
add chains/tendermint test
borngraced Oct 11, 2024
4cbd2fa
minor changes, improve api
borngraced Oct 14, 2024
a57495d
remove subscription on session delete
borngraced Oct 14, 2024
c7e7de6
improve ledger external wallet connection checks
borngraced Oct 14, 2024
cc3c568
wc tx handling for tendermint
borngraced Oct 14, 2024
7683090
merge with dev and fix conflicts
borngraced Oct 14, 2024
5a574a6
complete persistent session storage with unit test for native and wasm
borngraced Oct 15, 2024
81ebee7
minor changes
borngraced Oct 15, 2024
46e3802
fix is ledger connection fn
borngraced Oct 17, 2024
500cb87
module refactorings
borngraced Oct 19, 2024
b2dea85
Merge branch 'dev' of github.com:KomodoPlatform/komodo-defi-framework…
borngraced Oct 20, 2024
1840ca8
introduce WcRequstOps trait, untighten code and more
borngraced Oct 21, 2024
6501134
commit cargo.lock
borngraced Oct 21, 2024
38dadbe
implement cosmos ledger amino sign support
borngraced Oct 21, 2024
301a5b0
fix fmt
borngraced Oct 21, 2024
3cde05b
start eth pubkey mode impl
borngraced Oct 22, 2024
5eb3e4c
save progress - impl wc eth_personal sign
borngraced Oct 22, 2024
b35bd4a
implement eth coin activation using walletconnect
borngraced Oct 23, 2024
337154c
eth walletconnect coin activation and message handler code improvements
borngraced Oct 24, 2024
b358825
improve session message handling process
borngraced Oct 24, 2024
afc4058
further wc improve message handling
borngraced Oct 24, 2024
18eb62f
uncommit mm2_test_helpers lock file
borngraced Oct 24, 2024
9c083ac
eth wc transaction - save dev state
borngraced Oct 25, 2024
7f37fd3
impl eth withdraw for walletconnect policy
borngraced Oct 26, 2024
6e57330
don't support sign_raw_tx rpc in walletconnect mode
borngraced Oct 26, 2024
e45243b
cleanups
borngraced Oct 27, 2024
a8d937e
improvements to session, wc ops, and more
borngraced Oct 28, 2024
1569ede
create connection with custom namespaces
borngraced Oct 28, 2024
4fc5a43
impl eth sign and send tx for WalletConnect
borngraced Oct 31, 2024
3792027
swaps working, impl connection health manager
borngraced Nov 1, 2024
0b1da04
remove debug log
borngraced Nov 1, 2024
f0659a4
connection_handler improvements
borngraced Nov 1, 2024
187bf5e
improve tendermint wc code
borngraced Nov 2, 2024
2a2f167
use const_hex
borngraced Nov 2, 2024
cd368bf
major changes to connection handling and other minor fixes
borngraced Nov 3, 2024
0c61287
add logging to wc storage impl
borngraced Nov 3, 2024
fe0d096
Merge branch 'refs/heads/dev' into wc-integration
borngraced Nov 3, 2024
a0220d7
fix conflict and minor changes + merge with dev branch
borngraced Nov 3, 2024
3468502
minor changes
borngraced Nov 4, 2024
c4a07e4
monitor if relay client is connected
borngraced Nov 4, 2024
1e78257
changes to client impls
borngraced Nov 6, 2024
a43dc60
handle broadcast option for WalletConnect and some minor fixes
borngraced Nov 6, 2024
eea1532
remove unused
borngraced Nov 6, 2024
fb9f8c1
fix: handle unexpected end of file
borngraced Nov 6, 2024
d58b18f
re-enable use_watcher
borngraced Nov 6, 2024
045625b
cleanups
borngraced Nov 6, 2024
65c7f90
fix websocket connection drop
borngraced Nov 12, 2024
2326959
handle conn drop for session creation
borngraced Nov 12, 2024
42eaa29
nits
borngraced Nov 12, 2024
4ad423e
Merge branch 'refs/heads/dev' into wc-integration
borngraced Nov 12, 2024
e82083a
fix conflict after merge
borngraced Nov 12, 2024
ad38241
nits
borngraced Nov 12, 2024
59db165
move storage to session manager and minor improvements
borngraced Nov 13, 2024
f5caa19
fix review notes
borngraced Nov 13, 2024
bb186c2
fix: self review
borngraced Nov 15, 2024
77d7909
fix review notes
borngraced Nov 16, 2024
0d3fdfe
increase rpc timeout and return PublicKey from recover
borngraced Nov 18, 2024
35d0fa4
fix review notes
borngraced Nov 18, 2024
db1e687
fmt
borngraced Nov 18, 2024
11d114d
remove dup session delete rpc
borngraced Nov 19, 2024
af91d47
rename var and remove unnecessary sorting from storage sessions loading
borngraced Nov 19, 2024
10e9e67
refactor wait_for_tx_appears_on_rpc to use secs for time
borngraced Nov 19, 2024
b9075ce
batch subscribe to topics
borngraced Nov 26, 2024
1ff17cd
rename ctx.session to ctx.session_manager
borngraced Nov 26, 2024
5e89b9f
use weak spawner to spawn wc related task/event loops
borngraced Nov 27, 2024
1fec24f
validate table name only during initialization
borngraced Nov 27, 2024
bdf9636
make required_namespaces required for wc activation and remove defaults
borngraced Nov 27, 2024
31c9594
use sync mutex for active topic
borngraced Nov 27, 2024
37a36f7
fix review notes
borngraced Nov 28, 2024
0351d67
Merge branch 'dev' into wc-integration
borngraced Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions mm2src/kdf_walletconnect/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::sync::Arc;
use tokio::sync::Mutex;
use std::sync::{Arc, Mutex};
use wc_common::SymKey;

pub(crate) const FIVE_MINUTES: u64 = 5 * 60;
Expand Down Expand Up @@ -224,7 +223,7 @@ impl SessionManager {
self.0
.active_topic
.lock()
.await
.unwrap()
.clone()
.ok_or(MmError::new(WalletConnectError::SessionError(
"No active session".to_owned(),
Expand All @@ -235,7 +234,7 @@ impl SessionManager {
/// If a session with the same topic already exists, it will be overwritten.
pub(crate) async fn add_session(&self, session: Session) {
// set active session topic.
*self.0.active_topic.lock().await = Some(session.topic.clone());
*self.0.active_topic.lock().unwrap() = Some(session.topic.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such funcs were made async exclusively because of the async lock. we can make them sync now.

// insert session
self.0.sessions.insert(session.topic.clone(), session);
}
Expand All @@ -244,7 +243,7 @@ impl SessionManager {
/// If the session does not exist, this method does nothing.
pub(crate) async fn delete_session(&self, topic: &Topic) -> Option<Session> {
info!("[{topic}] Deleting session with topic");
let mut active_topic = self.0.active_topic.lock().await;
let mut active_topic = self.0.active_topic.lock().unwrap();

// Remove the session and get the removed session (if any)
let removed_session = self.0.sessions.remove(topic).map(|(_, session)| session);
Expand All @@ -263,7 +262,7 @@ impl SessionManager {
}

pub async fn set_active_session(&self, topic: &Topic) -> MmResult<(), WalletConnectError> {
let mut active_topic = self.0.active_topic.lock().await;
let mut active_topic = self.0.active_topic.lock().unwrap();
let session = self
.get_session(topic)
.ok_or(MmError::new(WalletConnectError::SessionError(
Expand All @@ -288,7 +287,7 @@ impl SessionManager {
self.0
.active_topic
.lock()
.await
.unwrap()
.as_ref()
.and_then(|topic| self.get_session(topic))
}
Expand Down
Loading