From 70480d427f3ae4950995a5f43a47286c037c561b Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Wed, 4 Mar 2026 13:23:02 -0500 Subject: [PATCH] Add Discord and Telegram social link support --- go.mod | 2 +- go.sum | 4 ++-- ocp/data/currency/model.go | 2 ++ ocp/data/currency/tests/tests.go | 10 ++++++++++ ocp/rpc/currency/metadata.go | 22 ++++++++++++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3d5717e..7b78412 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( filippo.io/edwards25519 v1.1.0 github.com/aws/aws-sdk-go-v2 v0.17.0 github.com/code-payments/code-vm-indexer v1.2.0 - github.com/code-payments/ocp-protobuf-api v1.1.0 + github.com/code-payments/ocp-protobuf-api v1.1.1-0.20260304181551-b9bda6eb3667 github.com/emirpasic/gods v1.12.0 github.com/envoyproxy/protoc-gen-validate v1.2.1 github.com/golang/protobuf v1.5.4 diff --git a/go.sum b/go.sum index 94130d8..9e4c76c 100644 --- a/go.sum +++ b/go.sum @@ -78,8 +78,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/code-payments/code-vm-indexer v1.2.0 h1:rSHpBMiT9BKgmKcXg/VIoi/h0t7jNxGx07Qz59m+6Q0= github.com/code-payments/code-vm-indexer v1.2.0/go.mod h1:vn91YN2qNqb+gGJeZe2+l+TNxVmEEiRHXXnIn2Y40h8= -github.com/code-payments/ocp-protobuf-api v1.1.0 h1:K9GUH7FX84hqXfR6Kgc/aTXE0lus3wU3lqcvFcf7szg= -github.com/code-payments/ocp-protobuf-api v1.1.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8= +github.com/code-payments/ocp-protobuf-api v1.1.1-0.20260304181551-b9bda6eb3667 h1:uGnk9MQEfKnuAay6PQBj3HZqCvexVL40VfTShFrsj/Y= +github.com/code-payments/ocp-protobuf-api v1.1.1-0.20260304181551-b9bda6eb3667/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= diff --git a/ocp/data/currency/model.go b/ocp/data/currency/model.go index 860673f..acc8a7e 100644 --- a/ocp/data/currency/model.go +++ b/ocp/data/currency/model.go @@ -24,6 +24,8 @@ const ( SocialLinkTypeUnknown SocialLinkType = iota SocialLinkTypeWebsite SocialLinkTypeX + SocialLinkTypeTelegram + SocialLinkTypeDiscord ) type SocialLink struct { diff --git a/ocp/data/currency/tests/tests.go b/ocp/data/currency/tests/tests.go index 7029d7a..b3d5855 100644 --- a/ocp/data/currency/tests/tests.go +++ b/ocp/data/currency/tests/tests.go @@ -152,6 +152,8 @@ func testMetadataRoundTrip(t *testing.T, s currency.Store) { SocialLinks: []currency.SocialLink{ {Type: currency.SocialLinkTypeWebsite, Value: "https://flipcash.com"}, {Type: currency.SocialLinkTypeX, Value: "jeffycurrency"}, + {Type: currency.SocialLinkTypeTelegram, Value: "jeffycurrency"}, + {Type: currency.SocialLinkTypeDiscord, Value: "abc123"}, }, Seed: "H7WNaHtCa5h2k7AwZ8DbdLfM6bU2bi2jmWiUkFqgeBYk", @@ -765,6 +767,8 @@ func testMetadataSaveWithVersioning(t *testing.T, s currency.Store) { record.SocialLinks = []currency.SocialLink{ {Type: currency.SocialLinkTypeWebsite, Value: "https://updated.example.com"}, {Type: currency.SocialLinkTypeX, Value: "updatedhandle"}, + {Type: currency.SocialLinkTypeTelegram, Value: "updatedtelegram"}, + {Type: currency.SocialLinkTypeDiscord, Value: "updateddiscord"}, } record.Alt = "updatedalt1111111111111111111111111111111111111" require.NoError(t, s.SaveMetadata(context.Background(), record)) @@ -782,6 +786,8 @@ func testMetadataSaveWithVersioning(t *testing.T, s currency.Store) { assert.Equal(t, []currency.SocialLink{ {Type: currency.SocialLinkTypeWebsite, Value: "https://updated.example.com"}, {Type: currency.SocialLinkTypeX, Value: "updatedhandle"}, + {Type: currency.SocialLinkTypeTelegram, Value: "updatedtelegram"}, + {Type: currency.SocialLinkTypeDiscord, Value: "updateddiscord"}, }, actual.SocialLinks) assert.Equal(t, "updatedalt1111111111111111111111111111111111111", actual.Alt) @@ -796,6 +802,8 @@ func testMetadataSaveWithVersioning(t *testing.T, s currency.Store) { record.SocialLinks = []currency.SocialLink{ {Type: currency.SocialLinkTypeWebsite, Value: "https://updated2.example.com"}, {Type: currency.SocialLinkTypeX, Value: "updatedhandle2"}, + {Type: currency.SocialLinkTypeTelegram, Value: "staletelegram"}, + {Type: currency.SocialLinkTypeDiscord, Value: "stalediscord"}, } record.Alt = "stalealt1111111111111111111111111111111111111111" record.State = currency.MetadataStateUnknown @@ -813,6 +821,8 @@ func testMetadataSaveWithVersioning(t *testing.T, s currency.Store) { assert.Equal(t, []currency.SocialLink{ {Type: currency.SocialLinkTypeWebsite, Value: "https://updated.example.com"}, {Type: currency.SocialLinkTypeX, Value: "updatedhandle"}, + {Type: currency.SocialLinkTypeTelegram, Value: "updatedtelegram"}, + {Type: currency.SocialLinkTypeDiscord, Value: "updateddiscord"}, }, actual.SocialLinks) assert.Equal(t, "updatedalt1111111111111111111111111111111111111", actual.Alt) } diff --git a/ocp/rpc/currency/metadata.go b/ocp/rpc/currency/metadata.go index 088f3eb..daead13 100644 --- a/ocp/rpc/currency/metadata.go +++ b/ocp/rpc/currency/metadata.go @@ -222,6 +222,18 @@ func (s *currencyServer) GetMints(ctx context.Context, req *currencypb.GetMintsR X: ¤cypb.SocialLink_X{Username: link.Value}, }, }) + case currency.SocialLinkTypeTelegram: + protoMetadata.SocialLinks = append(protoMetadata.SocialLinks, ¤cypb.SocialLink{ + Type: ¤cypb.SocialLink_Telegram_{ + Telegram: ¤cypb.SocialLink_Telegram{Username: link.Value}, + }, + }) + case currency.SocialLinkTypeDiscord: + protoMetadata.SocialLinks = append(protoMetadata.SocialLinks, ¤cypb.SocialLink{ + Type: ¤cypb.SocialLink_Discord_{ + Discord: ¤cypb.SocialLink_Discord{InviteCode: link.Value}, + }, + }) } } } @@ -297,6 +309,16 @@ func (s *currencyServer) UpdateMetadata(ctx context.Context, req *currencypb.Upd Type: currency.SocialLinkTypeX, Value: t.X.Username, }) + case *currencypb.SocialLink_Telegram_: + socialLinks = append(socialLinks, currency.SocialLink{ + Type: currency.SocialLinkTypeTelegram, + Value: t.Telegram.Username, + }) + case *currencypb.SocialLink_Discord_: + socialLinks = append(socialLinks, currency.SocialLink{ + Type: currency.SocialLinkTypeDiscord, + Value: t.Discord.InviteCode, + }) } } metadataRecord.SocialLinks = socialLinks