From d62d33fa3113c5ec97a720353d0ef3e8d86e2b60 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:11:37 -0800 Subject: [PATCH] Add prefix to namespace --- pkg/db/pgx.go | 3 ++- pkg/utils/namespace.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/db/pgx.go b/pkg/db/pgx.go index 1d36261b..3a6197cb 100644 --- a/pkg/db/pgx.go +++ b/pkg/db/pgx.go @@ -71,7 +71,8 @@ func isValidNamespace(namespace string) error { // PostgreSQL identifiers must start with a letter or underscore if !allowedNamespaceRe.MatchString(namespace) { return fmt.Errorf( - "namespace must start with a letter or underscore and contain only letters, numbers, and underscores", + "namespace must start with a letter or underscore and contain only letters, numbers, and underscores. Instead is %s", + namespace, ) } return nil diff --git a/pkg/utils/namespace.go b/pkg/utils/namespace.go index 67276c16..0e2542b6 100644 --- a/pkg/utils/namespace.go +++ b/pkg/utils/namespace.go @@ -1,6 +1,8 @@ package utils import ( + "fmt" + ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/xmtp/xmtpd/pkg/config" ) @@ -11,5 +13,5 @@ func BuildNamespace(options config.ServerOptions) string { []byte(options.Contracts.NodesContractAddress), ) - return HexEncode(hash)[:12] + return fmt.Sprintf("xmtpd_%s", HexEncode(hash)[:12]) }