From 293ff52599d1eb16610688419154b126cd53f8a3 Mon Sep 17 00:00:00 2001 From: harjotsinghgill <86789159+harjotsinghgill@users.noreply.github.com> Date: Thu, 3 Jul 2025 15:15:44 +0530 Subject: [PATCH 1/2] Add Redbelly blockchain and network support --- chain.go | 2 ++ did.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/chain.go b/chain.go index 838e30a..52cc0dc 100644 --- a/chain.go +++ b/chain.go @@ -38,6 +38,8 @@ var chainIDs = map[chainIDKey]ChainID{ {Billions, Test}: 6913, {Linea, Main}: 59144, {Linea, Sepolia}: 59141, + {Redbelly, Mainnet}: 151, + {Redbelly, Testnet}: 153, } // ChainIDfromDID returns chain name from w3c.DID diff --git a/did.go b/did.go index af02fd9..2fc4317 100644 --- a/did.go +++ b/did.go @@ -34,6 +34,8 @@ const ( DIDMethodIden3 DIDMethod = "iden3" // DIDMethodPolygonID DIDMethodPolygonID DIDMethod = "polygonid" + // DIDMethodReceptor + DIDMethodReceptor DIDMethod = "receptor" // DIDMethodOther any other method not listed before DIDMethodOther DIDMethod = "" ) @@ -41,6 +43,7 @@ const ( var didMethods = map[DIDMethod]DIDMethod{ DIDMethodIden3: DIDMethodIden3, DIDMethodPolygonID: DIDMethodPolygonID, + DIDMethodReceptor: DIDMethodReceptor, DIDMethodOther: DIDMethodOther, } @@ -68,6 +71,8 @@ const ( Billions Blockchain = "billions" // Linea is Linea blockchain network Linea Blockchain = "linea" + // Redbelly is Redbelly blockchain network + Redbelly Blockchain = "redbelly" // UnknownChain is used when it's not possible to retrieve blockchain type from identifier UnknownChain Blockchain = "unknown" // ReadOnly should be used for readonly identity to build readonly flag @@ -82,6 +87,7 @@ var blockchains = map[Blockchain]Blockchain{ Privado: Privado, Billions: Billions, Linea: Linea, + Redbelly: Redbelly, UnknownChain: UnknownChain, ReadOnly: ReadOnly, NoChain: NoChain, @@ -137,6 +143,14 @@ const ( Cardona NetworkID = "cardona" ) +// Redbelly-specific NetworkIDs +const ( + // Mainnet is Redbelly mainnet + Mainnet NetworkID = "mainnet" + // Testnet is Redbelly testnet + Testnet NetworkID = "testnet" +) + var networks = map[NetworkID]NetworkID{ Main: Main, Mumbai: Mumbai, @@ -146,6 +160,8 @@ var networks = map[NetworkID]NetworkID{ Goerli: Goerli, Sepolia: Sepolia, Test: Test, + Mainnet: Mainnet, + Testnet: Testnet, UnknownNetwork: UnknownNetwork, NoNetwork: NoNetwork, } @@ -169,6 +185,7 @@ func RegisterNetwork(n NetworkID) error { var DIDMethodByte = map[DIDMethod]byte{ DIDMethodIden3: 0b00000001, DIDMethodPolygonID: 0b00000010, + DIDMethodReceptor: 0b10000011, DIDMethodOther: 0b11111111, } @@ -224,12 +241,16 @@ var blockchainNetworkMap = map[DIDNetworkFlag]byte{ {Blockchain: Linea, NetworkID: Main}: 0b0100_0000 | 0b0000_1001, {Blockchain: Linea, NetworkID: Sepolia}: 0b0100_0000 | 0b0000_1000, + + {Blockchain: Redbelly, NetworkID: Mainnet}: 0b01010111, + {Blockchain: Redbelly, NetworkID: Testnet}: 0b10000011, } // DIDMethodNetwork is map for did methods and their blockchain networks var DIDMethodNetwork = map[DIDMethod]map[DIDNetworkFlag]byte{ DIDMethodIden3: blockchainNetworkMap, DIDMethodPolygonID: blockchainNetworkMap, + DIDMethodReceptor: blockchainNetworkMap, DIDMethodOther: { {Blockchain: UnknownChain, NetworkID: UnknownNetwork}: 0b1111_1111, }, From 8bfbed75c22bfdd454c35df0f8bc4473ea70d69c Mon Sep 17 00:00:00 2001 From: harjotsinghgill <86789159+harjotsinghgill@users.noreply.github.com> Date: Thu, 3 Jul 2025 15:15:53 +0530 Subject: [PATCH 2/2] Add test cases for Redbelly DID on mainnet and testnet --- did_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/did_test.go b/did_test.go index 6d20ccc..fc1f7e6 100644 --- a/did_test.go +++ b/did_test.go @@ -243,6 +243,20 @@ func TestDID_Build_From_Types(t *testing.T) { net: Sepolia, wantDID: "did:iden3:linea:sepolia:28itzVLBHnMHocFAeArLFYHP59J7WN1s5JwL8yGpQw", }, + { + title: "Receptor | Redbelly, mainnet", + method: DIDMethodReceptor, + chain: Redbelly, + net: Mainnet, + wantDID: "did:receptor:redbelly:mainnet:31A9FG7T3SZpaoU7b77yRBXt682Y8Z6vK7PHhgrUAAB", + }, + { + title: "Receptor | Redbelly, testnet", + method: DIDMethodReceptor, + chain: Redbelly, + net: Testnet, + wantDID: "did:receptor:redbelly:testnet:31Jxbg6JJG5xFqUbfEEFEKrDyBQsQHEgzN7JdBWRkCg", + }, } for i := range testCases {