Skip to content

Commit

Permalink
Add Privado chain as a part of a core library
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Jun 19, 2024
1 parent 51634fe commit b242267
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var chainIDs = map[chainIDKey]ChainID{
{Polygon, Amoy}: 80002,
{ZkEVM, Main}: 1101,
{ZkEVM, Test}: 1442,
{Privado, Main}: 21000,
{Privado, Test}: 21001,
}

// ChainIDfromDID returns chain name from w3c.DID
Expand Down
6 changes: 6 additions & 0 deletions did.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const (
Polygon Blockchain = "polygon"
// ZkEVM is zkEVM blockchain network
ZkEVM Blockchain = "zkevm"
// Privado is Privado blockchain network
Privado Blockchain = "privado"
// 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
Expand All @@ -76,6 +78,7 @@ var blockchains = map[Blockchain]Blockchain{
Ethereum: Ethereum,
Polygon: Polygon,
ZkEVM: ZkEVM,
Privado: Privado,
UnknownChain: UnknownChain,
ReadOnly: ReadOnly,
NoChain: NoChain,
Expand Down Expand Up @@ -195,6 +198,9 @@ var blockchainNetworkMap = map[DIDNetworkFlag]byte{

{Blockchain: ZkEVM, NetworkID: Main}: 0b0011_0000 | 0b0000_0001,
{Blockchain: ZkEVM, NetworkID: Test}: 0b0011_0000 | 0b0000_0010,

{Blockchain: Privado, NetworkID: Main}: 0b1010_0000 | 0b0000_0001,
{Blockchain: Privado, NetworkID: Test}: 0b1010_0000 | 0b0000_0010,
}

// DIDMethodNetwork is map for did methods and their blockchain networks
Expand Down
16 changes: 15 additions & 1 deletion did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestDIDFromID(t *testing.T) {
did.String())
}

func TestDID_PolygonID_Types(t *testing.T) {
func TestDID_Build_From_Types(t *testing.T) {
testCases := []struct {
title string
method DIDMethod
Expand Down Expand Up @@ -201,6 +201,20 @@ func TestDID_PolygonID_Types(t *testing.T) {
net: Test,
wantDID: "did:polygonid:zkevm:test:2wcMpvr8NgWTfqN6ChaFEx1qRnLREXhjeoJ45pFyw5",
},
{
title: "Iden3 | Privado chain, main",
method: DIDMethodIden3,
chain: Privado,
net: Main,
wantDID: "did:iden3:privado:main:2SZDsdYordSGMMQVXTVbCb7W834NBTBpkKZUAFRoGb",
},
{
title: "Iden3 | Privado chain, test",
method: DIDMethodIden3,
chain: Privado,
net: Test,
wantDID: "did:iden3:privado:test:2Skqvp4vnSFtq5bgAXbDs1Fs4AA5QGpRut9mCDew5R",
},
}

for i := range testCases {
Expand Down

0 comments on commit b242267

Please sign in to comment.