Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Privado chain as a part of a core library #463

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading