Skip to content

Commit 50d66f1

Browse files
committed
feat: new deeplink status-im->status-app
Signed-off-by: yqrashawn <[email protected]>
1 parent d3558d8 commit 50d66f1

File tree

6 files changed

+48
-21
lines changed

6 files changed

+48
-21
lines changed

protocol/chat.go

+18-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"math/rand"
8+
"strings"
89
"time"
910

1011
"github.com/status-im/status-go/deprecation"
@@ -16,6 +17,7 @@ import (
1617
"github.com/status-im/status-go/protocol/protobuf"
1718
"github.com/status-im/status-go/protocol/requests"
1819
v1protocol "github.com/status-im/status-go/protocol/v1"
20+
"github.com/status-im/status-go/services/utils"
1921
)
2022

2123
var chatColors = []string{
@@ -501,18 +503,30 @@ func CreateCommunityChat(orgID, chatID string, orgChat *protobuf.CommunityChat,
501503

502504
func (c *Chat) DeepLink() string {
503505
if c.OneToOne() {
504-
return "status-im://p/" + c.ID
506+
return "status-app://p/" + c.ID
505507
}
506508
if c.PrivateGroupChat() {
507-
return "status-im://g/args?a2=" + c.ID
509+
return "status-app://g/args?a2=" + c.ID
508510
}
509511

510512
if c.CommunityChat() {
511-
return "status-im://cc/" + c.ID
513+
communityChannelID := strings.TrimPrefix(c.ID, c.CommunityID)
514+
pubkey, err := types.DecodeHex(c.CommunityID)
515+
if err != nil {
516+
return ""
517+
}
518+
519+
serializedCommunityID, err := utils.SerializePublicKey(pubkey)
520+
521+
if err != nil {
522+
return ""
523+
}
524+
525+
return "status-app://cc/" + communityChannelID + "#" + serializedCommunityID
512526
}
513527

514528
if c.Public() {
515-
return "status-im://" + c.ID
529+
return "status-app://" + c.ID
516530
}
517531

518532
return ""

protocol/chat_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,13 @@ func (s *ChatTestSuite) TestUpdateFirstMessageTimestamp() {
162162
setAndCheck(FirstMessageTimestampNoMessage, false, 200)
163163
setAndCheck(100, true, 100)
164164
}
165+
166+
func (s *ChatTestSuite) TestDeepLink() {
167+
chat := &Chat{
168+
CommunityID: "0x02b1188c997e666cd5505ffd5c4b5fdbe3084b78a486d8e709da3b32ad3708a89e",
169+
ID: "0x02b1188c997e666cd5505ffd5c4b5fdbe3084b78a486d8e709da3b32ad3708a89ec432709e-fc73-440d-bb67-cb3a0929dfda",
170+
ChatType: ChatTypeCommunityChat,
171+
}
172+
173+
s.Require().Equal(chat.DeepLink(), "status-app://cc/c432709e-fc73-440d-bb67-cb3a0929dfda#zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo")
174+
}

protocol/local_notifications.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (n NotificationBody) toCommunityRequestToJoinNotification(id string) *local
156156
Message: n.Contact.PrimaryName() + " wants to join message " + n.Community.Name(),
157157
BodyType: localnotifications.TypeMessage,
158158
Category: localnotifications.CategoryCommunityRequestToJoin,
159-
Deeplink: "status-im://cr/" + n.Community.IDString(),
159+
Deeplink: "status-app://cr/" + n.Community.IDString(),
160160
Image: "",
161161
}
162162
}

protocol/messenger_share_urls.go

+1-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/golang/protobuf/proto"
99

10-
"github.com/status-im/status-go/api/multiformat"
1110
"github.com/status-im/status-go/eth-node/crypto"
1211
"github.com/status-im/status-go/eth-node/types"
1312
"github.com/status-im/status-go/protocol/common"
@@ -52,20 +51,7 @@ const baseShareURL = "https://status.app"
5251
const channelUUIDRegExp = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$"
5352

5453
func (m *Messenger) SerializePublicKey(compressedKey types.HexBytes) (string, error) {
55-
rawKey, err := crypto.DecompressPubkey(compressedKey)
56-
if err != nil {
57-
return "", err
58-
}
59-
pubKey := types.EncodeHex(crypto.FromECDSAPub(rawKey))
60-
61-
secp256k1Code := "0xe701"
62-
base58btc := "z"
63-
multiCodecKey := secp256k1Code + strings.TrimPrefix(pubKey, "0x")
64-
cpk, err := multiformat.SerializePublicKey(multiCodecKey, base58btc)
65-
if err != nil {
66-
return "", err
67-
}
68-
return cpk, nil
54+
return utils.SerializePublicKey(compressedKey)
6955
}
7056

7157
func (m *Messenger) DeserializePublicKey(compressedKey string) (types.HexBytes, error) {

services/local-notifications/transaction.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
type transactionState string
1919

2020
const (
21-
walletDeeplinkPrefix = "status-im://wallet/"
21+
walletDeeplinkPrefix = "status-app://wallet/"
2222

2323
failed transactionState = "failed"
2424
inbound transactionState = "inbound"

services/utils/utils.go

+17
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,20 @@ func DeserializePublicKey(compressedKey string) (types.HexBytes, error) {
4141

4242
return crypto.CompressPubkey(pubKey), nil
4343
}
44+
45+
func SerializePublicKey(compressedKey types.HexBytes) (string, error) {
46+
rawKey, err := crypto.DecompressPubkey(compressedKey)
47+
if err != nil {
48+
return "", err
49+
}
50+
pubKey := types.EncodeHex(crypto.FromECDSAPub(rawKey))
51+
52+
secp256k1Code := "0xe701"
53+
base58btc := "z"
54+
multiCodecKey := secp256k1Code + strings.TrimPrefix(pubKey, "0x")
55+
cpk, err := multiformat.SerializePublicKey(multiCodecKey, base58btc)
56+
if err != nil {
57+
return "", err
58+
}
59+
return cpk, nil
60+
}

0 commit comments

Comments
 (0)