diff --git a/VERSION b/VERSION index 04f0f3198..178a18b2a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.171.31 +0.171.32 diff --git a/services/wallet/api.go b/services/wallet/api.go index 95f66588c..9148bf268 100644 --- a/services/wallet/api.go +++ b/services/wallet/api.go @@ -671,30 +671,24 @@ func (api *API) WCPairSessionProposal(ctx context.Context, sessionProposalJSON s return api.s.walletConnect.PairSessionProposal(data) } -// WCRecordSuccessfulPairing confirms that a pairing has been established -func (api *API) WCRecordSuccessfulPairing(ctx context.Context, sessionProposalJSON string) error { - log.Debug("wallet.api.wc.RecordSuccessfulPairing", "proposal.len", len(sessionProposalJSON)) +// WCSaveOrUpdateSession records a session established between Status app and dapp +func (api *API) WCSaveOrUpdateSession(ctx context.Context, sessionProposalJSON string) error { + log.Debug("wallet.api.wc.WCSaveOrUpdateSession", "proposal.len", len(sessionProposalJSON)) - var data wc.SessionProposal + var data wc.Session err := json.Unmarshal([]byte(sessionProposalJSON), &data) if err != nil { return err } - return api.s.walletConnect.RecordSuccessfulPairing(data) + return api.s.walletConnect.SaveOrUpdateSession(data) } -// WCChangePairingState changes the active state of a pairing -func (api *API) WCChangePairingState(ctx context.Context, topic walletconnect.Topic, active bool) error { - log.Debug("wallet.api.wc.ChangePairingState", "topic", topic, "active", active) +// WCChangeSessionState changes the active state of a session +func (api *API) WCChangeSessionState(ctx context.Context, topic walletconnect.Topic, active bool) error { + log.Debug("wallet.api.wc.WCChangeSessionState", "topic", topic, "active", active) - return api.s.walletConnect.ChangePairingState(topic, active) -} - -func (api *API) WCHasActivePairings(ctx context.Context) (bool, error) { - log.Debug("wallet.api.wc.HasActivePairings") - - return api.s.walletConnect.HasActivePairings() + return api.s.walletConnect.ChangeSessionState(topic, active) } // WCSessionRequest responds to "session_request" event diff --git a/services/wallet/walletconnect/database.go b/services/wallet/walletconnect/database.go index 8a3a9ed09..0d0d88979 100644 --- a/services/wallet/walletconnect/database.go +++ b/services/wallet/walletconnect/database.go @@ -5,26 +5,62 @@ import ( "errors" ) -type Pairing struct { - Topic Topic `json:"topic"` - Expiry int64 `json:"expiry"` - Active bool `json:"active"` - AppName string `json:"appName"` - URL string `json:"url"` - Description string `json:"description"` - Icon string `json:"icon"` - Verified Verified `json:"verified"` +type DbSession struct { + Topic Topic `json:"topic"` + PairingTopic Topic `json:"pairingTopic"` + Expiry int64 `json:"expiry"` + Active bool `json:"active"` + DappName string `json:"dappName"` + DappURL string `json:"dappUrl"` + DappDescription string `json:"dappDescription"` + DappIcon string `json:"dappIcon"` + DappVerifyURL string `json:"dappVerifyUrl"` + DappPublicKey string `json:"dappPublicKey"` } -func InsertPairing(db *sql.DB, pairing Pairing) error { - insertSQL := `INSERT INTO wallet_connect_pairings (topic, expiry_timestamp, active, app_name, url, description, icon, verified_is_scam, verified_origin, verified_verify_url, verified_validation) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` +func UpsertSession(db *sql.DB, session DbSession) error { + insertSQL := ` + INSERT OR IGNORE INTO + wallet_connect_sessions (topic, pairing_topic, expiry, active) + VALUES + (?, ?, ?, ?); - _, err := db.Exec(insertSQL, pairing.Topic, pairing.Expiry, pairing.Active, pairing.AppName, pairing.URL, pairing.Description, pairing.Icon, pairing.Verified.IsScam, pairing.Verified.Origin, pairing.Verified.VerifyURL, pairing.Verified.Validation) + UPDATE + wallet_connect_sessions + SET + pairing_topic = ?, + expiry = ?, + active = ?, + dapp_name = ?, + dapp_url = ?, + dapp_description = ?, + dapp_icon = ?, + dapp_verify_url = ?, + dapp_publicKey = ? + WHERE + topic = ?;` + + _, err := db.Exec(insertSQL, + session.Topic, + session.PairingTopic, + session.Expiry, + session.Active, + session.PairingTopic, + session.Expiry, + session.Active, + session.DappName, + session.DappURL, + session.DappDescription, + session.DappIcon, + session.DappVerifyURL, + session.DappPublicKey, + session.Topic, + ) return err } -func ChangePairingState(db *sql.DB, topic Topic, active bool) error { - stmt, err := db.Prepare("UPDATE wallet_connect_pairings SET active = ? WHERE topic = ?") +func ChangeSessionState(db *sql.DB, topic Topic, active bool) error { + stmt, err := db.Prepare("UPDATE wallet_connect_sessions SET active = ? WHERE topic = ?") if err != nil { return err } @@ -39,29 +75,92 @@ func ChangePairingState(db *sql.DB, topic Topic, active bool) error { return err } if rowsAffected == 0 { - return errors.New("unable to locate pairing entry for DB state change") + return errors.New("unable to locate session for DB state change") } return nil } -func GetPairingByTopic(db *sql.DB, topic Topic) (*Pairing, error) { - querySQL := `SELECT topic, expiry_timestamp, active, app_name, url, description, icon, verified_is_scam, verified_origin, verified_verify_url, verified_validation FROM wallet_connect_pairings WHERE topic = ?` +func GetSessionByTopic(db *sql.DB, topic Topic) (*DbSession, error) { + querySQL := ` + SELECT * + FROM + wallet_connect_sessions + WHERE + topic = ?` row := db.QueryRow(querySQL, topic) - var pairing Pairing - err := row.Scan(&pairing.Topic, &pairing.Expiry, &pairing.Active, &pairing.AppName, &pairing.URL, &pairing.Description, &pairing.Icon, &pairing.Verified.IsScam, &pairing.Verified.Origin, &pairing.Verified.VerifyURL, &pairing.Verified.Validation) + var session DbSession + err := row.Scan(&session.Topic, + &session.PairingTopic, + &session.Expiry, + &session.Active, + &session.DappName, + &session.DappURL, + &session.DappDescription, + &session.DappIcon, + &session.DappVerifyURL, + &session.DappPublicKey) if err != nil { return nil, err } - return &pairing, nil + return &session, nil } -// GetActivePairings returns all active pairings (active and not expired) that have an expiry timestamp newer or equal to the given timestamp. -func GetActivePairings(db *sql.DB, expiryNotOlderThanTimestamp int64) ([]Pairing, error) { - querySQL := `SELECT topic, expiry_timestamp, active, app_name, url, description, icon, verified_is_scam, verified_origin, verified_verify_url, verified_validation FROM wallet_connect_pairings WHERE active != 0 AND expiry_timestamp >= ? ORDER BY expiry_timestamp DESC` +func GetSessionsByPairingTopic(db *sql.DB, pairingTopic Topic) ([]DbSession, error) { + querySQL := ` + SELECT * + FROM + wallet_connect_sessions + WHERE + pairing_topic = ?` + + rows, err := db.Query(querySQL, pairingTopic) + if err != nil { + return nil, err + } + defer rows.Close() + + sessions := make([]DbSession, 0, 2) + for rows.Next() { + var session DbSession + err := rows.Scan(&session.Topic, + &session.PairingTopic, + &session.Expiry, + &session.Active, + &session.DappName, + &session.DappURL, + &session.DappDescription, + &session.DappIcon, + &session.DappVerifyURL, + &session.DappPublicKey) + if err != nil { + return nil, err + } + + sessions = append(sessions, session) + } + + if err := rows.Err(); err != nil { + return nil, err + } + + return sessions, nil +} + +// GetActiveSessions returns all active sessions (active and not expired) that have an expiry timestamp newer or equal to the given timestamp. +func GetActiveSessions(db *sql.DB, expiryNotOlderThanTimestamp int64) ([]DbSession, error) { + querySQL := ` + SELECT * + FROM + wallet_connect_sessions + WHERE + active != 0 AND + expiry >= ? + ORDER BY + expiry DESC` rows, err := db.Query(querySQL, expiryNotOlderThanTimestamp) if err != nil { @@ -69,35 +168,29 @@ func GetActivePairings(db *sql.DB, expiryNotOlderThanTimestamp int64) ([]Pairing } defer rows.Close() - pairings := make([]Pairing, 0, 2) + sessions := make([]DbSession, 0, 2) for rows.Next() { - var pairing Pairing - err := rows.Scan(&pairing.Topic, &pairing.Expiry, &pairing.Active, &pairing.AppName, &pairing.URL, &pairing.Description, &pairing.Icon, &pairing.Verified.IsScam, &pairing.Verified.Origin, &pairing.Verified.VerifyURL, &pairing.Verified.Validation) + var session DbSession + err := rows.Scan(&session.Topic, + &session.PairingTopic, + &session.Expiry, + &session.Active, + &session.DappName, + &session.DappURL, + &session.DappDescription, + &session.DappIcon, + &session.DappVerifyURL, + &session.DappPublicKey) if err != nil { return nil, err } - if err := rows.Err(); err != nil { - return nil, err - } - pairings = append(pairings, pairing) + + sessions = append(sessions, session) } + if err := rows.Err(); err != nil { return nil, err } - return pairings, nil -} - -func HasActivePairings(db *sql.DB, expiryNotOlderThanTimestamp int64) (bool, error) { - querySQL := `SELECT EXISTS(SELECT 1 FROM wallet_connect_pairings WHERE active != 0 AND expiry_timestamp >= ?)` - - row := db.QueryRow(querySQL, expiryNotOlderThanTimestamp) - - var exists bool - err := row.Scan(&exists) - if err != nil { - return false, err - } - - return exists, nil + return sessions, nil } diff --git a/services/wallet/walletconnect/database_test.go b/services/wallet/walletconnect/database_test.go index bfe15fb00..06c3b605b 100644 --- a/services/wallet/walletconnect/database_test.go +++ b/services/wallet/walletconnect/database_test.go @@ -20,67 +20,110 @@ func setupTestDB(t *testing.T) (db *sql.DB, close func()) { } } -// generateTestData generates alternative disconnected and active pairings starting with the active one +// generateTestData generates alternative disconnected and active sessions starting with the active one // timestamps start with 1234567890 -func generateTestData(count int) []Pairing { - res := make([]Pairing, count) +func generateTestData(count int) []DbSession { + res := make([]DbSession, count) + j := 0 for i := 0; i < count; i++ { strI := strconv.Itoa(i) - res[i] = Pairing{ - Topic: Topic(strI + "abcdef1234567890"), - Expiry: 1234567890 + int64(i), - Active: (i % 2) == 0, - AppName: "TestApp" + strI, - URL: "https://test.url/" + strI, - Description: "Test Description" + strI, - Icon: "https://test.icon" + strI, - Verified: Verified{ - IsScam: false, - Origin: "https://test.origin/" + strI, - VerifyURL: "https://test.verify.url/" + strI, - Validation: "https://test.validation/" + strI, - }, + if i%4 == 0 { + j++ + } + strJ := strconv.Itoa(j) + res[i] = DbSession{ + Topic: Topic(strI + "aaaaaa1234567890"), + PairingTopic: Topic(strJ + "bbbbbb1234567890"), + Expiry: 1234567890 + int64(i), + Active: (i % 2) == 0, + DappName: "TestApp" + strI, + DappURL: "https://test.url/" + strI, + DappDescription: "Test Description" + strI, + DappIcon: "https://test.icon" + strI, + DappVerifyURL: "https://test.verify.url/" + strI, + DappPublicKey: strI + "1234567890", } } return res } -func insertTestData(t *testing.T, db *sql.DB, entries []Pairing) { +func insertTestData(t *testing.T, db *sql.DB, entries []DbSession) { for _, entry := range entries { - err := InsertPairing(db, entry) + err := UpsertSession(db, entry) require.NoError(t, err) } } -func TestInsertAndGetPairing(t *testing.T) { +func TestInsertUpdateAndGetSession(t *testing.T) { db, close := setupTestDB(t) defer close() entry := generateTestData(1)[0] - err := InsertPairing(db, entry) + err := UpsertSession(db, entry) require.NoError(t, err) - retrievedPairing, err := GetPairingByTopic(db, entry.Topic) + retrievedSession, err := GetSessionByTopic(db, entry.Topic) require.NoError(t, err) - require.Equal(t, entry, *retrievedPairing) + require.Equal(t, entry, *retrievedSession) + + entry.Active = false + entry.Expiry = 1111111111 + err = UpsertSession(db, entry) + + require.NoError(t, err) + + retrievedSession, err = GetSessionByTopic(db, entry.Topic) + require.NoError(t, err) + + require.Equal(t, entry, *retrievedSession) } -func TestChangePairingState(t *testing.T) { +func TestInsertAndGetSessionsByPairingTopic(t *testing.T) { + db, close := setupTestDB(t) + defer close() + + generatedSessions := generateTestData(10) + for _, session := range generatedSessions { + err := UpsertSession(db, session) + require.NoError(t, err) + } + + retrievedSessions, err := GetSessionsByPairingTopic(db, generatedSessions[4].Topic) + require.NoError(t, err) + require.Equal(t, 0, len(retrievedSessions)) + + retrievedSessions, err = GetSessionsByPairingTopic(db, generatedSessions[4].PairingTopic) + require.NoError(t, err) + require.Equal(t, 4, len(retrievedSessions)) + + for i := 4; i < 8; i++ { + found := false + for _, session := range retrievedSessions { + if session.Topic == generatedSessions[i].Topic { + found = true + require.Equal(t, generatedSessions[i], session) + } + } + require.True(t, found) + } +} + +func TestChangeSessionState(t *testing.T) { db, close := setupTestDB(t) defer close() entry := generateTestData(1)[0] - err := InsertPairing(db, entry) + err := UpsertSession(db, entry) require.NoError(t, err) - err = ChangePairingState(db, entry.Topic, false) + err = ChangeSessionState(db, entry.Topic, false) require.NoError(t, err) - retrievedPairing, err := GetPairingByTopic(db, entry.Topic) + retrievedSession, err := GetSessionByTopic(db, entry.Topic) require.NoError(t, err) - require.Equal(t, false, retrievedPairing.Active) + require.Equal(t, false, retrievedSession.Active) } func TestGet(t *testing.T) { @@ -90,42 +133,42 @@ func TestGet(t *testing.T) { entries := generateTestData(3) insertTestData(t, db, entries) - retrievedPairing, err := GetPairingByTopic(db, entries[1].Topic) + retrievedSession, err := GetSessionByTopic(db, entries[1].Topic) require.NoError(t, err) - require.Equal(t, entries[1], *retrievedPairing) + require.Equal(t, entries[1], *retrievedSession) } -func TestGetActivePairings(t *testing.T) { +func TestGetActiveSessions(t *testing.T) { db, close := setupTestDB(t) defer close() - // insert two disconnected and three active pairing + // insert two disconnected and three active sessions entries := generateTestData(5) insertTestData(t, db, entries) - activePairings, err := GetActivePairings(db, 1234567892) + activeSessions, err := GetActiveSessions(db, 1234567892) require.NoError(t, err) - require.Equal(t, 2, len(activePairings)) + require.Equal(t, 2, len(activeSessions)) // Expect newest on top - require.Equal(t, entries[4], activePairings[0]) - require.Equal(t, entries[2], activePairings[1]) + require.Equal(t, entries[4], activeSessions[0]) + require.Equal(t, entries[2], activeSessions[1]) } -func TestHasActivePairings(t *testing.T) { - db, close := setupTestDB(t) - defer close() +// func TestHasActivePairings(t *testing.T) { +// db, close := setupTestDB(t) +// defer close() - // insert one disconnected and two active pairing - entries := generateTestData(2) - insertTestData(t, db, entries) +// // insert one disconnected and two active pairing +// entries := generateTestData(2) +// insertTestData(t, db, entries) - hasActivePairings, err := HasActivePairings(db, 1234567890) - require.NoError(t, err) - require.True(t, hasActivePairings) +// hasActivePairings, err := HasActivePairings(db, 1234567890) +// require.NoError(t, err) +// require.True(t, hasActivePairings) - hasActivePairings, err = HasActivePairings(db, 1234567891) - require.NoError(t, err) - require.False(t, hasActivePairings) -} +// hasActivePairings, err = HasActivePairings(db, 1234567891) +// require.NoError(t, err) +// require.False(t, hasActivePairings) +// } diff --git a/services/wallet/walletconnect/service.go b/services/wallet/walletconnect/service.go index 79b446e31..a181cfd77 100644 --- a/services/wallet/walletconnect/service.go +++ b/services/wallet/walletconnect/service.go @@ -4,7 +4,6 @@ import ( "database/sql" "fmt" "strings" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" @@ -128,29 +127,28 @@ func (s *Service) PairSessionProposal(proposal SessionProposal) (*PairSessionRes return result, nil } -func (s *Service) RecordSuccessfulPairing(proposal SessionProposal) error { +func (s *Service) SaveOrUpdateSession(session Session) error { var icon string - if len(proposal.Params.Proposer.Metadata.Icons) > 0 { - icon = proposal.Params.Proposer.Metadata.Icons[0] + if len(session.Peer.Metadata.Icons) > 0 { + icon = session.Peer.Metadata.Icons[0] } - return InsertPairing(s.db, Pairing{ - Topic: proposal.Params.PairingTopic, - Expiry: proposal.Params.Expiry, - Active: true, - AppName: proposal.Params.Proposer.Metadata.Name, - URL: proposal.Params.Proposer.Metadata.URL, - Description: proposal.Params.Proposer.Metadata.Description, - Icon: icon, - Verified: proposal.Params.Verify.Verified, + + return UpsertSession(s.db, DbSession{ + Topic: session.Topic, + PairingTopic: session.PairingTopic, + Expiry: session.Expiry, + Active: true, + DappName: session.Peer.Metadata.Name, + DappURL: session.Peer.Metadata.URL, + DappDescription: session.Peer.Metadata.Description, + DappIcon: icon, + DappVerifyURL: session.Peer.Metadata.VerifyURL, + DappPublicKey: session.Peer.PublicKey, }) } -func (s *Service) ChangePairingState(topic Topic, active bool) error { - return ChangePairingState(s.db, topic, active) -} - -func (s *Service) HasActivePairings() (bool, error) { - return HasActivePairings(s.db, time.Now().Unix()) +func (s *Service) ChangeSessionState(topic Topic, active bool) error { + return ChangeSessionState(s.db, topic, active) } func (s *Service) SessionRequest(request SessionRequest) (response *transfer.TxResponse, err error) { diff --git a/services/wallet/walletconnect/walletconnect.go b/services/wallet/walletconnect/walletconnect.go index fcd926ca8..a193456de 100644 --- a/services/wallet/walletconnect/walletconnect.go +++ b/services/wallet/walletconnect/walletconnect.go @@ -101,6 +101,20 @@ type SessionDelete struct { Topic Topic `json:"topic"` } +type Session struct { + Acknowledged bool `json:"acknowledged"` + Controller string `json:"controller"` + Expiry int64 `json:"expiry"` + Namespaces map[string]Namespace `json:"namespaces"` + OptionalNamespaces map[string]Namespace `json:"optionalNamespaces"` + PairingTopic Topic `json:"pairingTopic"` + Peer Proposer `json:"peer"` + Relay json.RawMessage `json:"relay"` + RequiredNamespaces map[string]Namespace `json:"requiredNamespaces"` + Self Proposer `json:"self"` + Topic Topic `json:"topic"` +} + // Valid namespace func (n *Namespace) Valid(namespaceName string, chainID *uint64) bool { if chainID == nil { diff --git a/walletdatabase/migrations/bindata.go b/walletdatabase/migrations/bindata.go index a8d0cc841..34b4c2f0e 100644 --- a/walletdatabase/migrations/bindata.go +++ b/walletdatabase/migrations/bindata.go @@ -13,6 +13,7 @@ // 1699987075_add_timestamp_and_state_to_community_data_cache.up.sql (865B) // 1700414564_add_wallet_connect_pairings_table.up.sql (439B) // 1701101493_add_token_blocks_range.up.sql (469B) +// 1702467441_wallet_connect_sessions_instead_of_pairings.up.sql (356B) // doc.go (74B) package migrations @@ -97,7 +98,7 @@ func _1691753758_initialUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1691753758_initial.up.sql", size: 5738, mode: os.FileMode(0644), modTime: time.Unix(1701079799, 0)} + info := bindataFileInfo{name: "1691753758_initial.up.sql", size: 5738, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6b, 0x25, 0x31, 0xc8, 0x27, 0x3, 0x6b, 0x9f, 0x15, 0x42, 0x2f, 0x85, 0xfb, 0xe3, 0x6, 0xea, 0xf7, 0x97, 0x12, 0x56, 0x3c, 0x9a, 0x5b, 0x1a, 0xca, 0xb1, 0x23, 0xfa, 0xcd, 0x57, 0x25, 0x5c}} return a, nil } @@ -117,7 +118,7 @@ func _1692701329_add_collectibles_and_collections_data_cacheUpSql() (*asset, err return nil, err } - info := bindataFileInfo{name: "1692701329_add_collectibles_and_collections_data_cache.up.sql", size: 1808, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1692701329_add_collectibles_and_collections_data_cache.up.sql", size: 1808, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0x51, 0xf4, 0x2b, 0x92, 0xde, 0x59, 0x65, 0xd8, 0x9b, 0x57, 0xe0, 0xfd, 0x7b, 0x12, 0xb, 0x29, 0x6e, 0x9d, 0xb5, 0x90, 0xe, 0xfa, 0x12, 0x97, 0xd, 0x61, 0x60, 0x7f, 0x32, 0x1d, 0xc3}} return a, nil } @@ -137,7 +138,7 @@ func _1692701339_add_scope_to_pendingUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1692701339_add_scope_to_pending.up.sql", size: 576, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1692701339_add_scope_to_pending.up.sql", size: 576, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x36, 0x8a, 0x5e, 0xe2, 0x63, 0x15, 0x37, 0xba, 0x55, 0x18, 0xf3, 0xcc, 0xe0, 0x5, 0x84, 0xe1, 0x5b, 0xe8, 0x1, 0x32, 0x6b, 0x9f, 0x7d, 0x9f, 0xd9, 0x23, 0x6c, 0xa9, 0xb5, 0xdc, 0xf4, 0x93}} return a, nil } @@ -157,7 +158,7 @@ func _1694540071_add_collectibles_ownership_update_timestampUpSql() (*asset, err return nil, err } - info := bindataFileInfo{name: "1694540071_add_collectibles_ownership_update_timestamp.up.sql", size: 349, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1694540071_add_collectibles_ownership_update_timestamp.up.sql", size: 349, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7f, 0x45, 0xc7, 0xce, 0x79, 0x63, 0xbc, 0x6f, 0x83, 0x5f, 0xe2, 0x3, 0x56, 0xcc, 0x5, 0x2f, 0x85, 0xda, 0x7e, 0xea, 0xf5, 0xd2, 0xac, 0x19, 0xd4, 0xd8, 0x5e, 0xdd, 0xed, 0xe2, 0xa9, 0x97}} return a, nil } @@ -177,7 +178,7 @@ func _1694692748_add_raw_balance_to_token_balancesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1694692748_add_raw_balance_to_token_balances.up.sql", size: 165, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1694692748_add_raw_balance_to_token_balances.up.sql", size: 165, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd4, 0xe0, 0x5b, 0x42, 0xf0, 0x96, 0xa5, 0xf5, 0xed, 0xc0, 0x97, 0x88, 0xb0, 0x6d, 0xfe, 0x7d, 0x97, 0x2e, 0x17, 0xd2, 0x16, 0xbc, 0x2a, 0xf2, 0xcc, 0x67, 0x9e, 0xc5, 0x47, 0xf6, 0x69, 0x1}} return a, nil } @@ -197,7 +198,7 @@ func _1695133989_add_community_id_to_collectibles_and_collections_data_cacheUpSq return nil, err } - info := bindataFileInfo{name: "1695133989_add_community_id_to_collectibles_and_collections_data_cache.up.sql", size: 275, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1695133989_add_community_id_to_collectibles_and_collections_data_cache.up.sql", size: 275, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfa, 0x2, 0xa, 0x7f, 0x4b, 0xd1, 0x3, 0xd0, 0x3, 0x29, 0x84, 0x31, 0xed, 0x49, 0x4f, 0xb1, 0x2d, 0xd7, 0x80, 0x41, 0x5b, 0xfa, 0x6, 0xae, 0xb4, 0xf6, 0x6b, 0x49, 0xee, 0x57, 0x33, 0x76}} return a, nil } @@ -217,7 +218,7 @@ func _1695932536_balance_history_v2UpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1695932536_balance_history_v2.up.sql", size: 653, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1695932536_balance_history_v2.up.sql", size: 653, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x37, 0xf4, 0x14, 0x91, 0xf6, 0x5f, 0xc4, 0x9b, 0xb7, 0x83, 0x32, 0x72, 0xbe, 0x82, 0x42, 0x39, 0xa4, 0x3b, 0xc9, 0x78, 0x3d, 0xca, 0xd4, 0xbf, 0xfc, 0x7a, 0x33, 0x1e, 0xcd, 0x9e, 0xe4, 0x85}} return a, nil } @@ -237,7 +238,7 @@ func _1696853635_input_dataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1696853635_input_data.up.sql", size: 23140, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1696853635_input_data.up.sql", size: 23140, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x89, 0x30, 0x33, 0x33, 0x55, 0xc5, 0x57, 0x2b, 0xaf, 0xef, 0x3d, 0x8d, 0x2a, 0xaa, 0x5c, 0x32, 0xd1, 0xf4, 0xd, 0x4a, 0xd0, 0x33, 0x4a, 0xe8, 0xf6, 0x8, 0x6b, 0x65, 0xcc, 0xba, 0xed, 0x42}} return a, nil } @@ -257,7 +258,7 @@ func _1698117918_add_community_id_to_tokensUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1698117918_add_community_id_to_tokens.up.sql", size: 61, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1698117918_add_community_id_to_tokens.up.sql", size: 61, mode: os.FileMode(0644), modTime: time.Unix(1700489912, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb3, 0x82, 0xdb, 0xde, 0x3, 0x3, 0xc, 0x67, 0xf3, 0x54, 0xc4, 0xad, 0xd6, 0xce, 0x56, 0xfb, 0xc1, 0x87, 0xd7, 0xda, 0xab, 0xec, 0x1, 0xe1, 0x7d, 0xb3, 0x63, 0xd6, 0xe5, 0x5d, 0x1c, 0x15}} return a, nil } @@ -277,7 +278,7 @@ func _1698257443_add_community_metadata_to_wallet_dbUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1698257443_add_community_metadata_to_wallet_db.up.sql", size: 323, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "1698257443_add_community_metadata_to_wallet_db.up.sql", size: 323, mode: os.FileMode(0644), modTime: time.Unix(1700489912, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x22, 0xd3, 0x4, 0x25, 0xfa, 0x23, 0x1, 0x48, 0x83, 0x26, 0x20, 0xf2, 0x3d, 0xbc, 0xc1, 0xa7, 0x7c, 0x27, 0x7c, 0x1d, 0x63, 0x3, 0xa, 0xd0, 0xce, 0x47, 0x86, 0xdc, 0xa1, 0x3c, 0x2, 0x1c}} return a, nil } @@ -297,7 +298,7 @@ func _1699987075_add_timestamp_and_state_to_community_data_cacheUpSql() (*asset, return nil, err } - info := bindataFileInfo{name: "1699987075_add_timestamp_and_state_to_community_data_cache.up.sql", size: 865, mode: os.FileMode(0644), modTime: time.Unix(1701152469, 0)} + info := bindataFileInfo{name: "1699987075_add_timestamp_and_state_to_community_data_cache.up.sql", size: 865, mode: os.FileMode(0644), modTime: time.Unix(1701075679, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc3, 0xee, 0x37, 0xf9, 0x7f, 0x9e, 0xfe, 0x93, 0x66, 0x2b, 0xd, 0x57, 0xf4, 0x89, 0x6c, 0x51, 0xfd, 0x14, 0xe9, 0xcd, 0xab, 0x65, 0xe7, 0xa7, 0x83, 0x7e, 0xe0, 0x5c, 0x14, 0x49, 0xf3, 0xe5}} return a, nil } @@ -317,7 +318,7 @@ func _1700414564_add_wallet_connect_pairings_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1700414564_add_wallet_connect_pairings_table.up.sql", size: 439, mode: os.FileMode(0644), modTime: time.Unix(1701326149, 0)} + info := bindataFileInfo{name: "1700414564_add_wallet_connect_pairings_table.up.sql", size: 439, mode: os.FileMode(0644), modTime: time.Unix(1702469123, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x77, 0x5e, 0x19, 0x62, 0x3c, 0x3a, 0x81, 0x16, 0xa0, 0x95, 0x35, 0x62, 0xab, 0x5e, 0x2b, 0xea, 0x11, 0x71, 0x11, 0xd0, 0x9, 0xab, 0x9c, 0xab, 0xf2, 0xdd, 0x5f, 0x88, 0x83, 0x9a, 0x93}} return a, nil } @@ -337,11 +338,31 @@ func _1701101493_add_token_blocks_rangeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1701101493_add_token_blocks_range.up.sql", size: 469, mode: os.FileMode(0644), modTime: time.Unix(1701435193, 0)} + info := bindataFileInfo{name: "1701101493_add_token_blocks_range.up.sql", size: 469, mode: os.FileMode(0644), modTime: time.Unix(1701936747, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe0, 0x37, 0xfb, 0x1a, 0x6c, 0x8c, 0xa8, 0x1e, 0xa2, 0xa5, 0x1f, 0x90, 0x73, 0x3e, 0x31, 0x5f, 0x48, 0x1e, 0x9a, 0x37, 0x27, 0x1c, 0xc, 0x67, 0x1, 0xcd, 0xec, 0x85, 0x4c, 0x1c, 0x26, 0x52}} return a, nil } +var __1702467441_wallet_connect_sessions_instead_of_pairingsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\xc1\x4a\x03\x31\x10\x86\xef\xfb\x14\x73\x54\xf0\x0d\x7a\xda\xea\x28\x4b\xd7\xa4\xa4\x11\xda\x53\x88\xe9\x28\x03\x31\x09\x49\x5a\xdd\xb7\x17\x42\x0f\x35\xf6\xfa\x7f\xdf\xfc\x30\xff\xa3\xc2\x51\x23\xe8\x71\x3d\x23\x4c\xcf\x20\xa4\x06\xdc\x4f\x3b\xbd\x83\x6f\xeb\x3d\x55\xe3\x62\x08\xe4\xaa\x29\x54\x0a\xc7\x50\xe0\x6e\x00\x00\xa8\x31\xb1\x03\x8d\x7b\x0d\x5b\x35\xbd\x8e\xea\x00\x1b\x3c\xb4\x7b\xf1\x36\xcf\x0f\x4d\x4a\x96\x33\x87\x4f\x73\x25\xff\x15\xe8\x27\x71\x5e\x60\x12\x1a\x5f\x50\x75\xd0\xba\xca\x67\x82\xb5\x94\x33\x8e\xa2\x83\x47\x9b\x92\x09\xf6\x8b\x5a\xed\x55\x76\xca\xbe\x8f\x8e\x54\x5c\xe6\x54\x39\x86\x1e\xb1\xfb\x9f\x9d\x29\xf3\xc7\x72\xab\x28\x9d\xde\x3d\xbb\x0d\x2d\x0d\x0c\xf7\xab\x61\x78\x52\x72\x7b\x99\xaf\x1b\xec\xf2\x7c\x59\xfd\x06\x00\x00\xff\xff\x24\xfa\x0d\x3a\x64\x01\x00\x00") + +func _1702467441_wallet_connect_sessions_instead_of_pairingsUpSqlBytes() ([]byte, error) { + return bindataRead( + __1702467441_wallet_connect_sessions_instead_of_pairingsUpSql, + "1702467441_wallet_connect_sessions_instead_of_pairings.up.sql", + ) +} + +func _1702467441_wallet_connect_sessions_instead_of_pairingsUpSql() (*asset, error) { + bytes, err := _1702467441_wallet_connect_sessions_instead_of_pairingsUpSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "1702467441_wallet_connect_sessions_instead_of_pairings.up.sql", size: 356, mode: os.FileMode(0644), modTime: time.Unix(1702472443, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x73, 0x5f, 0x0, 0x60, 0x6, 0x28, 0x76, 0x61, 0x39, 0xdc, 0xa1, 0x84, 0x80, 0x46, 0x8a, 0xe4, 0x42, 0xb5, 0x1f, 0x18, 0x14, 0x23, 0x46, 0xb9, 0x51, 0xf, 0x62, 0xac, 0xc, 0x7, 0x98, 0xe}} + return a, nil +} + var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2c\xc9\xb1\x0d\xc4\x20\x0c\x05\xd0\x9e\x29\xfe\x02\xd8\xfd\x6d\xe3\x4b\xac\x2f\x44\x82\x09\x78\x7f\xa5\x49\xfd\xa6\x1d\xdd\xe8\xd8\xcf\x55\x8a\x2a\xe3\x47\x1f\xbe\x2c\x1d\x8c\xfa\x6f\xe3\xb4\x34\xd4\xd9\x89\xbb\x71\x59\xb6\x18\x1b\x35\x20\xa2\x9f\x0a\x03\xa2\xe5\x0d\x00\x00\xff\xff\x60\xcd\x06\xbe\x4a\x00\x00\x00") func docGoBytes() ([]byte, error) { @@ -357,7 +378,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1699882401, 0)} + info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1700071475, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x7c, 0x28, 0xcd, 0x47, 0xf2, 0xfa, 0x7c, 0x51, 0x2d, 0xd8, 0x38, 0xb, 0xb0, 0x34, 0x9d, 0x4c, 0x62, 0xa, 0x9e, 0x28, 0xc3, 0x31, 0x23, 0xd9, 0xbb, 0x89, 0x9f, 0xa0, 0x89, 0x1f, 0xe8}} return a, nil } @@ -479,6 +500,8 @@ var _bindata = map[string]func() (*asset, error){ "1701101493_add_token_blocks_range.up.sql": _1701101493_add_token_blocks_rangeUpSql, + "1702467441_wallet_connect_sessions_instead_of_pairings.up.sql": _1702467441_wallet_connect_sessions_instead_of_pairingsUpSql, + "doc.go": docGo, } @@ -486,13 +509,11 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// -// data/ -// foo.txt -// img/ -// a.png -// b.png -// +// data/ +// foo.txt +// img/ +// a.png +// b.png // then AssetDir("data") would return []string{"foo.txt", "img"}, // AssetDir("data/img") would return []string{"a.png", "b.png"}, // AssetDir("foo.txt") and AssetDir("notexist") would return an error, and @@ -538,6 +559,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "1699987075_add_timestamp_and_state_to_community_data_cache.up.sql": &bintree{_1699987075_add_timestamp_and_state_to_community_data_cacheUpSql, map[string]*bintree{}}, "1700414564_add_wallet_connect_pairings_table.up.sql": &bintree{_1700414564_add_wallet_connect_pairings_tableUpSql, map[string]*bintree{}}, "1701101493_add_token_blocks_range.up.sql": &bintree{_1701101493_add_token_blocks_rangeUpSql, map[string]*bintree{}}, + "1702467441_wallet_connect_sessions_instead_of_pairings.up.sql": &bintree{_1702467441_wallet_connect_sessions_instead_of_pairingsUpSql, map[string]*bintree{}}, "doc.go": &bintree{docGo, map[string]*bintree{}}, }} diff --git a/walletdatabase/migrations/sql/1702467441_wallet_connect_sessions_instead_of_pairings.up.sql b/walletdatabase/migrations/sql/1702467441_wallet_connect_sessions_instead_of_pairings.up.sql new file mode 100644 index 000000000..c70e72842 --- /dev/null +++ b/walletdatabase/migrations/sql/1702467441_wallet_connect_sessions_instead_of_pairings.up.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS wallet_connect_sessions ( + topic TEXT PRIMARY KEY NOT NULL, + pairing_topic TEXT NOT NULL, + expiry INTEGER NOT NULL, + active BOOLEAN NOT NULL, + dapp_name TEXT, + dapp_url TEXT, + dapp_description TEXT, + dapp_icon TEXT, + dapp_verify_url TEXT, + dapp_publicKey TEXT +); + +DROP TABLE wallet_connect_pairings; \ No newline at end of file