feat: new deeplink status-im->status-app (#4198)
This commit is contained in:
parent
d3558d8e09
commit
b65eda3f42
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/status-im/status-go/deprecation"
|
||||
|
@ -16,6 +17,7 @@ import (
|
|||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/protocol/requests"
|
||||
v1protocol "github.com/status-im/status-go/protocol/v1"
|
||||
"github.com/status-im/status-go/services/utils"
|
||||
)
|
||||
|
||||
var chatColors = []string{
|
||||
|
@ -501,18 +503,30 @@ func CreateCommunityChat(orgID, chatID string, orgChat *protobuf.CommunityChat,
|
|||
|
||||
func (c *Chat) DeepLink() string {
|
||||
if c.OneToOne() {
|
||||
return "status-im://p/" + c.ID
|
||||
return "status-app://p/" + c.ID
|
||||
}
|
||||
if c.PrivateGroupChat() {
|
||||
return "status-im://g/args?a2=" + c.ID
|
||||
return "status-app://g/args?a2=" + c.ID
|
||||
}
|
||||
|
||||
if c.CommunityChat() {
|
||||
return "status-im://cc/" + c.ID
|
||||
communityChannelID := strings.TrimPrefix(c.ID, c.CommunityID)
|
||||
pubkey, err := types.DecodeHex(c.CommunityID)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
serializedCommunityID, err := utils.SerializePublicKey(pubkey)
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return "status-app://cc/" + communityChannelID + "#" + serializedCommunityID
|
||||
}
|
||||
|
||||
if c.Public() {
|
||||
return "status-im://" + c.ID
|
||||
return "status-app://" + c.ID
|
||||
}
|
||||
|
||||
return ""
|
||||
|
|
|
@ -162,3 +162,13 @@ func (s *ChatTestSuite) TestUpdateFirstMessageTimestamp() {
|
|||
setAndCheck(FirstMessageTimestampNoMessage, false, 200)
|
||||
setAndCheck(100, true, 100)
|
||||
}
|
||||
|
||||
func (s *ChatTestSuite) TestDeepLink() {
|
||||
chat := &Chat{
|
||||
CommunityID: "0x02b1188c997e666cd5505ffd5c4b5fdbe3084b78a486d8e709da3b32ad3708a89e",
|
||||
ID: "0x02b1188c997e666cd5505ffd5c4b5fdbe3084b78a486d8e709da3b32ad3708a89ec432709e-fc73-440d-bb67-cb3a0929dfda",
|
||||
ChatType: ChatTypeCommunityChat,
|
||||
}
|
||||
|
||||
s.Require().Equal(chat.DeepLink(), "status-app://cc/c432709e-fc73-440d-bb67-cb3a0929dfda#zQ3shZL6dXiFCbDyxnXxwQa9v8QFC2q19subFtyxd7kVszMVo")
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ func (n NotificationBody) toCommunityRequestToJoinNotification(id string) *local
|
|||
Message: n.Contact.PrimaryName() + " wants to join message " + n.Community.Name(),
|
||||
BodyType: localnotifications.TypeMessage,
|
||||
Category: localnotifications.CategoryCommunityRequestToJoin,
|
||||
Deeplink: "status-im://cr/" + n.Community.IDString(),
|
||||
Deeplink: "status-app://cr/" + n.Community.IDString(),
|
||||
Image: "",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
"github.com/status-im/status-go/api/multiformat"
|
||||
"github.com/status-im/status-go/eth-node/crypto"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/common"
|
||||
|
@ -52,20 +51,7 @@ const baseShareURL = "https://status.app"
|
|||
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}$"
|
||||
|
||||
func (m *Messenger) SerializePublicKey(compressedKey types.HexBytes) (string, error) {
|
||||
rawKey, err := crypto.DecompressPubkey(compressedKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
pubKey := types.EncodeHex(crypto.FromECDSAPub(rawKey))
|
||||
|
||||
secp256k1Code := "0xe701"
|
||||
base58btc := "z"
|
||||
multiCodecKey := secp256k1Code + strings.TrimPrefix(pubKey, "0x")
|
||||
cpk, err := multiformat.SerializePublicKey(multiCodecKey, base58btc)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return cpk, nil
|
||||
return utils.SerializePublicKey(compressedKey)
|
||||
}
|
||||
|
||||
func (m *Messenger) DeserializePublicKey(compressedKey string) (types.HexBytes, error) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
type transactionState string
|
||||
|
||||
const (
|
||||
walletDeeplinkPrefix = "status-im://wallet/"
|
||||
walletDeeplinkPrefix = "status-app://wallet/"
|
||||
|
||||
failed transactionState = "failed"
|
||||
inbound transactionState = "inbound"
|
||||
|
|
|
@ -41,3 +41,20 @@ func DeserializePublicKey(compressedKey string) (types.HexBytes, error) {
|
|||
|
||||
return crypto.CompressPubkey(pubKey), nil
|
||||
}
|
||||
|
||||
func SerializePublicKey(compressedKey types.HexBytes) (string, error) {
|
||||
rawKey, err := crypto.DecompressPubkey(compressedKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
pubKey := types.EncodeHex(crypto.FromECDSAPub(rawKey))
|
||||
|
||||
secp256k1Code := "0xe701"
|
||||
base58btc := "z"
|
||||
multiCodecKey := secp256k1Code + strings.TrimPrefix(pubKey, "0x")
|
||||
cpk, err := multiformat.SerializePublicKey(multiCodecKey, base58btc)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return cpk, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue